fcxSanya Posted June 20, 2011 Report Share Posted June 20, 2011 we can't seem to find the command to ungarrison unitsI think "unload"/"unload-all" commands is that what you need, you can see it here:http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 20, 2011 Author Report Share Posted June 20, 2011 (edited) I think "unload"/"unload-all" commands is that what you need, you can see it here:http://trac.wildfire...ers/Commands.jsThanks for that link! unfortunately, both didn't work.We got the following:JavaScript warning: simulation/helpers/Commands.js line 233Script value conversion check failed: JSVAL_IS_NUMBER(v) (got type undefined)any suggestions for what our engine call would have to look like? Edited June 20, 2011 by AI-Amsterdam Quote Link to comment Share on other sites More sharing options...
fcxSanya Posted June 20, 2011 Report Share Posted June 20, 2011 any suggestions for what our engine call would have to look like?Probably something like this:Engine.PostCommand({"type": "unload", "garrisonHolder": buildingEntity, "entity": unitEntityToUnload});Engine.PostCommand({"type": "unload-all", "garrisonHolder": buildingEntity}); Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 20, 2011 Author Report Share Posted June 20, 2011 (edited) Probably something like this:Engine.PostCommand({"type": "unload", "garrisonHolder": buildingEntity, "entity": unitEntityToUnload});Engine.PostCommand({"type": "unload-all", "garrisonHolder": buildingEntity});Yep, works like a charm . I think I know how to read that file now, so maybe we will ask less of this kind of questions.Is there a similar file which handles queries to the engine?@historic_bruno, where and how can we read these events?Also, we have up until now been working on windows, but we would like to do AI vs AI battles on linux. Do we have to build our whole code, or can we get away with a shortcut?Or is it possible to do an AI vs AI using windows command line? With the same query as the one on the previous page?Also, we are going to publish a part of our code (maybe today, maybe tomorow), and would like you all to rate it for the report we have to hand in this Friday. A quick look over our code would probably suffice, and we would be very thankful if you'd take the time to do that. Edited June 20, 2011 by AI-Amsterdam Quote Link to comment Share on other sites More sharing options...
k776 Posted June 20, 2011 Report Share Posted June 20, 2011 Sure, we'd be happy to take a look.It'd be great if you could release the whole source code under the GPL license the rest of the code is licensed with.That way, if you choose not to continue to develop it after you hand in your assignment, others might be able to pick up from where you leave it.Of course, you're more than welcome to continue developing it. It would be nice to be able to include another AI with Alpha 6. :-)Would you say the AI is less than 2 weeks from completion (or atleast, to a point of being playable without any errors)? Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 20, 2011 Author Report Share Posted June 20, 2011 It's definitely our intention that others can work with our AI after we've finished it. We think we've structured it better so that it's easier to change and add things now. We'll add more information this week on how it's structured.I think that the AI is playable in less than two weeks. Actually the plan is to have our AI beat JuBot by the end of this week so we could show that at our presentation. We'd love it if our AI was included in the next Alpha version. Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted June 21, 2011 Report Share Posted June 21, 2011 Is there a similar file which handles queries to the engine?Assuming you mean Engine.QueryInterface? That command accesses the interface of a simulation component, or the part of it that's been exposed to simulation scripts. There's no single place that documents all of them as far as I know, they're scattered through scripts (simulation\components) and C++ (source\simulation2\components). Components can be defined in C++ or JS along with their interface. But I believe they have this in common that they can only be accessed by other simulation code, so the AI for instance, must go through AIProxy.@historic_bruno, where and how can we read these events?Looks like simulation\ai\common-api\base.js is responsible for this, at least for a few of the possible events (the rest like "Attacked" are seemingly not implemented yet). I can't really give specific guidance on that part, as it was designed by Philip/Ykkrosh. For specifics, you might want to find him in IRC Or is it possible to do an AI vs AI using windows command line? With the same query as the one on the previous page?The command line arguments should be identical on Windows and Linux. Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 21, 2011 Author Report Share Posted June 21, 2011 (edited) Hey everyone! Thanks for helping us so far! We would like to ask you a small favor. We have to submit our code this Friday, and it would be nice if we got some input from the programmers (especially the ones involved in A.I. programming) from this forum. We have attached our code to this post, which does a few basic things (it is by no means a finished product, we are still adding things as we speak!). As you can tell by the name, our code uses behavior trees as a framework. This technique was developed for shooters, but we thought it could also be used for a real time strategy game.A behaviour tree is a tree with nodes which will constantly be traversed during the game. Each node has a condition, which decides if the node can be chosen as a child node. The children are evaluated by priority (starting with the child with the highest priority). If the condition is true, this child will be chosen, if it's not, the child with the next best priority will be evaluated. A node can also have actions associated with it, though usually only leaf nodes contain actions. When a leaf is reached the actions will be carried out, and the tree will be traversed from the root again. Would you be so kind as to answer the following questions? - Is this code easy to understand?- Is it easy to write a new module and integrate it with the existing tree? - How does this compare to the JuBot code in general? - Any ideas to improve our framework? - Anything else you would like to add?We tried running our bot via the command line on windows, but then it gave errors and warnings, while we don't have that problem if we run the game normally. Any ideas on why this is?The way locations for new buildings are picked is a bit strange (we tested primarily on the Death Canyon map), but we haven't changed the plan-building.js file so far. It would be a good idea to improve this at some point.AI-Amsterdam.zip Edited June 21, 2011 by AI-Amsterdam Quote Link to comment Share on other sites More sharing options...
Jeru Posted June 21, 2011 Report Share Posted June 21, 2011 Out of curiosity, can you divulge some more details about who you are? Number of participants, is this a university project, perhaps names (even first names), how you found 0 A.D. etc.If you wish to remain anonymous that is fine. Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 21, 2011 Author Report Share Posted June 21, 2011 Sure, we are four 2nd year Artificial Intelligence students: Sander, Michael, Richard and Anna (from the University of Amsterdam). We have chosen improving the AI from 0 A.D. as our 2nd year project of 4 weeks. We found 0 A.D. when we looked for open-source games and this one was the first one on the list And we all knew Age of Empires so we thought it would be fun to make an AI for this game. Quote Link to comment Share on other sites More sharing options...
Jeru Posted June 21, 2011 Report Share Posted June 21, 2011 Welcome, Sander, Michael, Richard and Anna, and thank you for your contributions. Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 21, 2011 Author Report Share Posted June 21, 2011 It seems we have forgotten to include the behavior tree, hehIt's a big image so here's the link; Behavior TreeHowever the tree is still under development, some nodes aren't implemented/included and changes are being made almost constantly. The tree might not be 100% up to date, but it should give you an idea on how it runs trough the code, and what were trying to do.Team AI-Amsterdam Quote Link to comment Share on other sites More sharing options...
satchitb Posted June 21, 2011 Report Share Posted June 21, 2011 Not a coder, but I just wanted to congratulate the team on creating this AI. I remember when I first got interested in 0AD, the AI was its biggest weakness in that it was barely functional. Now, we can create a dynamic and intelligent AI. 0AD is going to be awesome. Quote Link to comment Share on other sites More sharing options...
k776 Posted June 21, 2011 Report Share Posted June 21, 2011 Hey. Thanks for sharing the code.I don't have time to drill into it too much yet, but looking good so far!From a cosmetic standpoint, the code styles (indentation, curly braces) and file names could do with some unifying (different ways it's done at the moment).I personally use 2 space indentation, open curly brace on the same line as the function is defined, and one class per file (i saw one file with like 3 classes in it).The more consistent the code is, the better. The files could do with being split into folders too.e.g.rootbot/ _init.js data.json rootbot.js economy/ economy.js plan-buldings.js .... military/ buildDefence.js ...Other than that, awesome work. Can't wait to try play it later today. Quote Link to comment Share on other sites More sharing options...
Mythos_Ruler Posted June 21, 2011 Report Share Posted June 21, 2011 We found 0 A.D. when we looked for open-source games and this one was the first one on the list And we all knew Age of Empires so we thought it would be fun to make an AI for this game. Indeed it is!http://en.wikipedia.org/wiki/List_of_open-source_video_gamesI suppose the game's name is beneficial in this way, probably being at the beginning of any such list. Quote Link to comment Share on other sites More sharing options...
chaosislife Posted June 21, 2011 Report Share Posted June 21, 2011 Where do I stick the files at so I can try it out? Quote Link to comment Share on other sites More sharing options...
Badmadblacksad Posted June 21, 2011 Report Share Posted June 21, 2011 Where do I stick the files at so I can try it out?binaries/data/mods/public/simulation/ai Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted June 22, 2011 Report Share Posted June 22, 2011 I tried it out today. By the way, you can rename your version of the common-api folder to something like rootbot-api, and then include it in _init.js, that way it's easy to test changes Few comments on the behavior tree:1. Is the priority ordered from left to right (for nodes of equal depth)?2. I noticed females were stuck standing at the civil centre and only used for building - maybe they have been flagged as builders and not changed back to gatherers? There's no advantage though to having idle units, so women at least should always be gathering or building something.3. "if (poor) Economy" seems vague and covers many possibilities, what is a poor economy? Maybe it should be broken up into smaller tasks like the Attack tree, so the behavior is more explicit, for example:if (pop limit reached) -> build housesif (need workers) -> create more workersif (need resources) -> if (need food) -> if (domestic animal near) -> hunt -> if (fruit tree near) -> forage -> if (farm near) -> farm -> else -> build farm -> else -> if (resource site near) -> gather -> else -> build dropsiteif (idle workers) -> give orderselse -> balance economy for higher level plansAlthough there may be a reason why the tree was arranged that way, this is just a programmer's point of view, and not an AI designer's 4. Also it may not be clear, but "citizen-soldiers" can gather too. So, let's say you need resources fast and have some idle or defending citizen-soldiers, then you could order them to gather. Their templates use the CitizenSoldier class rather than Worker.As a general comment, the AI causes the game to lag severely on Acropolis map (2v2 AIs). Most of the time the lag is related to "economy update", particularly GatheringManager.update (you can see what's going on by pressing F11 during the game, then a number shown on the left side of the screen to expand the profiling info. The AI stuff is inside of 3-Simulation Update. It's hierarchical, so you can use Engine.ProfileStart/Stop inside of an existing profiling block to get more specific timings.)The resource gathering needs to be more balanced, they should probably be weighted so that there's a calculated minimum number of workers on each type of resource but where the weighting changes depending on various factors (stage of the game, the player's civ, etc.) What I'm seeing is suddenly there's 0 food, so send all workers to a farm, then suddenly we have 0 wood after building houses, so send all the workers to a forest, etc.I didn't see any military activity so that's why I commented only on economic behavior for now.We tried running our bot via the command line on windows, but then it gave errors and warnings, while we don't have that problem if we run the game normally. Any ideas on why this is?Which command did you try? Quote Link to comment Share on other sites More sharing options...
gudo Posted June 22, 2011 Report Share Posted June 22, 2011 I too didn't see any military activity, though I did notice RootBot creating hopolites and using them as gatherers. Another thing, I'm sure you know, but RootBot doesn't mine any metal. Also, it seems like it assigns nearly everyone to do the same task, and that creates an un-balanced economy. So even though it uses soldiers as gatherers, it still grows surprisingly slowly :/ Quote Link to comment Share on other sites More sharing options...
Rasunadon Posted June 22, 2011 Report Share Posted June 22, 2011 I suppose the game's name is beneficial in this way, probably being at the beginning of any such list. Yeah, it is better than Zero-K. Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 22, 2011 Author Report Share Posted June 22, 2011 Thanks for trying our AI out. @k776 We'll fix the identation and things like that when we've finished programming.@historic_brunoYes, the leafs under a node are also sorted on priority from left to right. If the WorkersManager is true, it will execute the code from the WorkersManager and it will not look at the other conditions of the leaves at that same level. If you want to change the priority of the leaves (or of the nodes) you just have to change the order of the children in the constructor of the node.We did write code that made the builders gatherers once they were finished building, but that wasn't working yesterday so we left it out. It does work now though And when we need builders again we pick the nearest builders next to the foundation.The condition for the EconomyManager is indeed vague, but it's hard to find a good condition for it, so now we have as a condition that it's true if one of the leaves is true. It's not really good, but we don't have much time to rearrange the EconomyManager.We've changed the GatheringManager so that it now gatherers a bit of everything and if there's an unaffordable plan, we shift a couple of workers to those resources. This is more similar to JuBot's code except that we look at the unaffordable plans too and change the weights. We did let the Citizensoldiers gather by the way.Our EconomyManager should be much more efficient now, because first we reassigned all the gatherers and now we only reassign the idle gatherers so it hopefully lags a little less now Oh and we've fixed the errors now btw.I think RootBot should attack the opponent when it has enough soldiers and siege units, but that takes a while and with the Celtics it didn't came into that node at all, because we didn't realise they had two fortresses with different names And we didn't include the defensive node, because it wasn't quite finished yet. Quote Link to comment Share on other sites More sharing options...
AI-Amsterdam Posted June 22, 2011 Author Report Share Posted June 22, 2011 (edited) Hey guys, we've improved our AI a little bit more this time. It now managed to defeat jubot on oasis as player 1 and player 2 (both greeks), and on death canyon as player 2 (iberians). We got a strange error there upon exiting though, but there was no error message unfortunately.It might still be a bit slow though, but maybe we will optimise our code some other time. Deadline is coming awfully close (about 7 hours from now, and we have to give a presentation, so an all-nighter is not an option) so we will probably stick with this for a while.Enjoy! And again, tell us what you think. Our report should be handed in tomorow (friday), so if you are quick, we could quote you in it.VICTORY IN OASIS.zip Edited June 23, 2011 by AI-Amsterdam Quote Link to comment Share on other sites More sharing options...
plumo Posted June 25, 2011 Report Share Posted June 25, 2011 I'm not on the dev team so I can't speak for them, but I hope you keep updating your A.I. I tested it yesterday, and I was impressed. Quote Link to comment Share on other sites More sharing options...
ribez Posted July 14, 2011 Report Share Posted July 14, 2011 someone has tested this AI? Quote Link to comment Share on other sites More sharing options...
lexa Posted July 19, 2011 Report Share Posted July 19, 2011 if (pop limit reached) -> build housesif (need workers) -> create more workersif (need resources) -> if (need food) -> if (domestic animal near) -> hunt -> if (fruit tree near) -> forage -> if (farm near) -> farm -> else -> build farm -> else -> if (resource site near) -> gather -> else -> build dropsiteif (idle workers) -> give orderselse -> balance economy for higher level plansAlthough there may be a reason why the tree was arranged that way, this is just a programmer's point of view, and not an AI designer's Hey, this is good, I take it for my bot If you have other "trees" like that, please do not hesitate to add them here, we discuss it and I will implement it soon since I have all the structure almost set for my bothttp://code.google.com/p/split-bot/wiki/BehaviorsI will test the RootBot tonightBye! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.