Jump to content

A challenger appears : Marilyn (Yet-yet another AI)


Recommended Posts

  • 2 weeks later...

Hello!

I've recently discovered 0 A.D. and also tried playing with this AI.

There is an error message given, whenever you have destroyed a military building of Marilyn.

It says: javascript error: military.js line 815:

I looked into the code and found this:

// processing events

for (var i in events) {

var e = events;

if (e.type === "Destroy") {

if (e.msg.rawEntity.template){

var ent = new Entity(gameState.ai, e.msg.rawEntity);

if (ent && ent.trainableEntities())

for (i in ent.trainableEntities())

this.UnitTrainingBuildings[ent.trainableEntities()].splice(this.UnitTrainingBuildings[ent.trainableEntities()].indexOf(ent.id()),1); this one is the line given out by error message in game

}

} else if (e.type == "ConstructionFinished") // construction of a unit generating entity (that's barracks…)

{

var ent = gameState.getEntityById(e.msg.newentity);

if (ent.trainableEntities())

for (i in ent.trainableEntities())

{

if (this.UnitTrainingBuildings[ent.trainableEntities()])

this.UnitTrainingBuildings[ent.trainableEntities()].push(ent.id());

}

}

}

It seems to me, the case is missing that a building is destroyed and therefore not erased from Marilyn's posessed buildings and the AI tries to build units in this building that just no longer exists.

Don't know how to fix this, for I don't have any experience with javascript.

Rest of Marilyn seems to be working fine. It does well at defending, especially when you have a direct border to its territory.

Hope this helps in improving this game further!!

Edited by Eurus
Link to comment
Share on other sites

BTW, I've given this 30 minutes today, and the thing is now basically "api-v2 compatible", which thanks the the unitAI state and the new entity collections, will prove useful in the long run.

Here's a breakdown of what is still to do (in gross order, but I'm forgetting things):

-finish upgrading the files

-finish the new plan manager, and make sure everything works properly

-rewrite the code for resource collecting by shifting the focus from the worker to the resource. (ie now, we for each worker look for a resource... I think doing the opposite would be better), or perhaps a mix of the two)

-rewrite the attack plans code to use entity collections… and a few other things

-write the enemy manager using entitycollections

-write the new micromanagement manager

-???

-Profit.

Link to comment
Share on other sites

  • 2 weeks later...

Okay, I've done this 5 good days of work during my holidays... I'm getting close to being on par with the former Marilyn, but not quite. I've also redone a ton of stuffs, because some things weren't fully logical, or simply to make it better.I'm using entity collections pretty much everywhere, it's fairly nice.

I'm going back to school in 3 days, and I'm going to have a lot of work for at least 3 weeks, I'm unsure how fast I'll go.

I'll probably also try to support technologies before releasing the new version.

Edited by wraitii
Link to comment
Share on other sites

Allright... This being my last day of holidays before at least 3 weeks of hard work ( :( ), I'm releasing Marilyn in its current state as a "proof of concept", if you will. Please report any error, suspicious warning, or weird behavior, this will allow me to tackle them when I have time. Note: it should only work with SVN.

There is one non-lethal known bug: sometimes, the game will freeze for ≈10 seconds, before resuming with lots of "out of memory" errors. Afaik, there is no following crash or problem, I don't know what causes this, any help is appreciated. If it causes a crash for you, please report.

Otherwise, I haven't really thoroughly checked, but it should be mostly working, at the very least in the 15 first minutes. I haven't actually played a game much longer than that since I started recoding, so I don't really know what could happen :) .

It does about all the things the former Marilyn did:

-Attacking. It will create armies, and will send them after the strongest enemy (I think), though it might get stuck sometimes, perhaps.

-Defend. Marilyn will reliably attack any incoming army, and will deal with animals and lonely scouts. I'm not too sure what happens if one of its unit is out of its territory, but that should be a fairly rare case. I think the defense manager is actually more reliable than the former one at this point, even though it's not yet fully implemented.

-Build stuff, much like the former Marilyn, only it chooses the templates dynamically using a system of roles.

-The economic aspect of things is basically the same, I haven't touched it much, but because the plan manager is not yet perfect, it may have a few troubles building enough villagers in the mid/late game.

What it doesn't do:

-Raiding... And some things during attacks, such as responding to being attacked. I haven't had times to recode this, as I've basically scrapped using the old Tactics Manager, and haven't really coded anything new to replace it.

-It's completely oblivious to technologies. Do not be surprised if Marilyn builds a fortress as its first military building.

-It won't build towers or fortresses for now (though most civs will likely build a fortress as its first military building, bar perhaps the Persians).

What it does better:

-The Defcon system for defense has been revamped, and now Marilyn will garrison/ungarrison females. The defense manager is also more clever, it's able to pause attack plans if it takes their units.

-It's not "better" per se, but Marilyn is now mostly dynamic for unit training and building. All civs are supported. This doesn't change much compared to qBot, but you'll notice Marilyn training champions for its attack plans instead of anything, and building fortresses instead of Barracks, things like that.

Technical side of things: I use entity collections everywhere. In the two "census "files, which are the unit/building info manager that Marilyn uses to know what it has/what it can build. In the defense manager, for enemy targeting/knowing which of my units attack. In the enemy watchers, that keep track of enemy armies. It's very neat, and very dynamic.

Quantumstate, if you read this and have some time, I think it could be interesting to look at the code (most notably in the attack plans/defense manager), there are likely some stuffs that you can put into qBot.

There might be a git repo in the file... Ignore it, I haven't updated yet.

Marilyn.zip

  • Like 1
Link to comment
Share on other sites

Thanks for the report, Pureon... I think it's again a case of unit garrisoning... I think you had an army of soldiers of some sort and you suddenly garrisoned all of them, causing the entity collection GetCentrePosition function return undefined.

Any other report?

Link to comment
Share on other sites

You're a very good beta-tester in that :D

Allright, it's fixed in the lazy way: it won't return an error, and the code should still work consistently. There's no practical and cheap way to check if the unit has a position in entityCollections.

Link to comment
Share on other sites

Ouch, that hurt :). i've got to learn to play this game properly...

Anyway, thanks for the test... I noticed Marilyn being quite confused when you attacked during her attack, which shouldn't be... Will look into that and this error.

Link to comment
Share on other sites

Yeah, Mythos and Bruno seem to be on that... I've sent him a PM about this, but then I figured that it's probably not too expensive to count the number of workers on any given resource at any time, so the PM I sent him is really a non-issue... I intend to fix it, and along with some clever UnitAI, it'll be.

Link to comment
Share on other sites

Allright, following Pueron's advice, I'm revising the economic manager, and making interesting progress. The new idea is that I keep a list of resources that I want to collect from for each resource type (ultimately, perhaps subtype too), and then I'll assign the most efficient workers to each. Still much of a WIP, but I think it can be very efficient.

And as it seems like Quantumstate added a way to count the number of entities working on a resource at any given time, I'll probably get some inspiration to do that from him.

Link to comment
Share on other sites

Allright, I originally intended to implement a complicated resource gathering system... Only, it's too complicated to be any kind of practical (because I need to plan for future unit creation, mainly).

So, I'm changing my plans to a much simpler system: I'll assign my females to food gathering, and citizen soldiers to the rest. This won't change during the game, unless there is a particular need (fast collecting for a fortress) or a discrepancy (say, after an attack). It should prove efficient, as it's what most players do, with great success.

Link to comment
Share on other sites

It works fairly well as long as the training follows... The hardest part is dealing with sudden needs (such as a fortress build) or with the aftermath of an attack, because you might want your females to chop wood or stuffs.

Testing a very basic version in the early game against the latest qBot, it seems about 600/700 resources more efficient...

Anyway, don't expect it too soon, I'm going to have a very busy week.

Link to comment
Share on other sites

  • 1 month later...

Allright, so being all busy with my work, and then wanting to rest, I haven't touched this in a few weeks... But I'll probably resume working on Marilyn soon. I've been able to at last actually play the game since I had a friend at my school download the game and we did a little LAN. Motivated me quite a bit. It was the longest time since I last played against a human (AOE II, how you remind me…).

Edited by wraitii
Link to comment
Share on other sites

Looks like I've lost some of the last progression I had done... Not too bad, since I was stuck in a bad place. I'll recode in the simplest way I can a way to have females gathering food and the other wood. Now on the other hand, I'll try to make it even more "self-aware" because while the architecture is in place, it's not really used... And increasingly prepared to technologies. Using my newly found knowledge of the game, which I acquired by playing it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...