lexa Posted July 13, 2011 Report Share Posted July 13, 2011 Hi I try to make my 1st contribution in AI scripting.Would you have some tips and tricks? Especially for testing, reproducing scenarios?I am looking for more examples of use of all the methods of the Entity classAnd like to know more about the difference of the methods Entity:setMetaData and the methods like Entity::moveThank you in advance,Bye Quote Link to comment Share on other sites More sharing options...
lexa Posted July 13, 2011 Author Report Share Posted July 13, 2011 For example, how to access these methods and structures from javascriptPlayer http://svn.wildfiregames.com/docs/classCCmpPlayerScripted.htmlEntity data struct http://svn.wildfiregames.com/docs/structEntityData.htmlEntity struct http://svn.wildfiregames.com/docs/structEntity.htmlPosition http://svn.wildfiregames.com/docs/classICmpPosition.htmldistance ordering filter http://svn.wildfiregames.com/docs/structEntityDistanceOrdering.htmlVisual element http://svn.wildfiregames.com/docs/classICmpVisual.html Quote Link to comment Share on other sites More sharing options...
lexa Posted July 14, 2011 Author Report Share Posted July 14, 2011 I feel a bit lonely here... But here is the google code project for my AI Bot, which I have called the Split Bot, read the description to understand why.I choose to develop in haXe which is a very structured language which can be "compiled" in javascript code.Here are the javascript common-api classes in haXe :http://code.google.com/p/split-bot/source/browse/#svn%2Ftrunk%2Fsrc%2Forg%2Fzeroad%2Fcommon_apiThese are haXe "extern"s which will link to the actual javascript classes of 0 A.D. at runtime. Quote Link to comment Share on other sites More sharing options...
k776 Posted July 14, 2011 Report Share Posted July 14, 2011 It's been less than 12 hours since your first post. Give it a day for people around the world to respond.As far as haXe goes, I'd have personally gone with CoffeeScript (http://jashkenas.github.com/coffee-script/) if I were writing code that compiles to JS. Quote Link to comment Share on other sites More sharing options...
lexa Posted July 14, 2011 Author Report Share Posted July 14, 2011 HiThank you for your answer I am very happy with haxe. It is really something you know...And I already have an AI Bot running. So now is the part where I am trying to look into Entity objects, I make them move or build and when I'll be comfortable, this will be the time to implement my logic! Bye! Quote Link to comment Share on other sites More sharing options...
gudo Posted July 14, 2011 Report Share Posted July 14, 2011 If you want my two cents, I'd suggest avoiding modifying the common API files (common-api/base.js class.js, etc) You see, there's no way to be sure that your changes will make it into the source. There's a ton of problems with this. Mainly the risk that your changes will break other bots and incompatibility with other common-api changing bots (RootBot for example.) Note though, those common-api's could still use a bit of development. If you want to make changes to the source, go ahead and register on trac and submit a ticket/patch.Are there any pre-compiled files that I could just throw into my install so I can try your bot out? Quote Link to comment Share on other sites More sharing options...
lexa Posted July 14, 2011 Author Report Share Posted July 14, 2011 (edited) Hi gudo, thank you for your interestIf you want my two cents, I'd suggest avoiding modifying the common API files (common-api/base.js class.js, etc) You see, there's no way to be sure that your changes will make it into the source. There's a ton of problems with this. Mainly the risk that your changes will break other bots and incompatibility with other common-api changing bots (RootBot for example.) I did not modify it, I did haXe extern classes, which is like an import at runtime, but it gives you auto completion and type checking.Note though, those common-api's could still use a bit of development. If you want to make changes to the source, go ahead and register on trac and submit a ticket/patch.I just did! There is a mistake in the common api I think: http://trac.wildfire....com/ticket/897Are there any pre-compiled files that I could just throw into my install so I can try your bot out?It is just a bit too early, for now it only traces some data...Thank you for your advice, bye!And my question remains:Do you know a place where these javascript classes are documented?TemplateStatePlayerMap Edited July 14, 2011 by lexa Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted July 14, 2011 Report Share Posted July 14, 2011 common-api and testbot were just my first unfinished prototype attempt at a design, so please don't take them too seriously as being perfect or complete or unchangeable . It's quite possible that they'll be redesigned entirely, if someone comes up with a better way of doing them. Also there's no guarantee of maintaining compatibility with AI scripts, given future changes to the script design or to the engine - we need more experience and a better design before being able to offer stability. The only documentation is this which is very minimal, and even that might change incompatibly.So the AI design isn't good or stable or documented yet - what we need is for people to experiment with it and identify problems and propose improvements, so that we can hopefully converge on something that works well, eventually Would you have some tips and tricks? Especially for testing, reproducing scenarios?The autostart command-line options are often useful for testing.And like to know more about the difference of the methods Entity:setMetaData and the methods like Entity::moveThe metadata thing is a way for AI scripts to associate arbitrary AI-specific data with entities (e.g. remembering whether they're meant to be a worker or a soldier etc), with a bit of engine support so you can assign metadata when training units and it will be remembered when the unit actually gets created. All other methods are either examining the entity's state at the beginning of the turn, or issuing commands that will be executed on the next turn.how to access these methods and structures from javascriptYou can't - AI scripts only have access to a snapshot of the simulation state that's passed into some common-api function every turn. (Files like binaries/data/mods/public/simulation/components/AIProxy.js are used when constructing that snapshot, and they're a normal simulation component.) Quote Link to comment Share on other sites More sharing options...
lexa Posted July 14, 2011 Author Report Share Posted July 14, 2011 HiThank you very much for these tips! It seems ok to me the common-api for now... So far there is only one bug whoch is bothering me http://trac.wildfiregames.com/ticket/897I would be glad to help improving it. I believe, the haxe "extern" classes are at least a fully typed version of the api. It is easyier to understand I guess.http://code.google.com/p/split-bot/source/browse/#svn%2Ftrunk%2Fsrc%2Forg%2Fzeroad%2Fcommon_apiI will keep you informed, bye! Quote Link to comment Share on other sites More sharing options...
gudo Posted July 31, 2011 Report Share Posted July 31, 2011 Updates? I've been keeping an eye on your google code page and I've noticed you've got a bit of work done. Any chance of a playble release soon? Quote Link to comment Share on other sites More sharing options...
Chakakhan Posted August 1, 2011 Report Share Posted August 1, 2011 Lexa, looks like you are off to a good start! I checked out your code page, very nice. Quote Link to comment Share on other sites More sharing options...
lexa Posted August 7, 2011 Author Report Share Posted August 7, 2011 HelloThank you very much for your encouragement. Back from vacation and back to 0ad.I am not sure about the decision tree yet, I have several ideas which I am testing... Anyway, I have a clean fully typed classes which map all the classes and objects of the common api (externs in haxe)I let you know when I have something serious to play with Bye! Quote Link to comment Share on other sites More sharing options...
lexa Posted August 16, 2011 Author Report Share Posted August 16, 2011 HelloI am about to release the 1st alpha version of the SplitBot AI bot, in haxe hereIt beats the other bots with 100% success (I tried about 5 times with each bot), but in fact the defense and attack are not implemented for now. It builds a decent village very quickly and grows a population of 200 workers before sending all "men" to the nearest enemy...And now I have a question: is it possible to accelerate time for testing the bot? I do not need the rendering during the "acceleration"..Thank you all,lexa. Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted August 16, 2011 Report Share Posted August 16, 2011 If you don't need any graphics at all, replay mode will run the simulation code blind. Otherwise you can run Engine.SetSimRate(10) in the in-game console to make it try to run 10x faster. Quote Link to comment Share on other sites More sharing options...
ribez Posted August 16, 2011 Report Share Posted August 16, 2011 HelloI am about to release the 1st alpha version of the SplitBot AI bot, in haxe hereIt beats the other bots with 100% success (I tried about 5 times with each bot), but in fact the defense and attack are not implemented for now. It builds a decent village very quickly and grows a population of 200 workers before sending all "men" to the nearest enemy...And now I have a question: is it possible to accelerate time for testing the bot? I do not need the rendering during the "acceleration"..Thank you all,lexa.maybe this can be useful? Quote Link to comment Share on other sites More sharing options...
Pureon Posted August 16, 2011 Report Share Posted August 16, 2011 And now I have a question: is it possible to accelerate time for testing the bot? I do not need the rendering during the "acceleration"..You can also 'time warp'. When in-game hit Shift-D to open the developer overlay window, select 'Enable time warp', then just hold down space to fast-forward the game. Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted August 16, 2011 Report Share Posted August 16, 2011 That too, though be careful in long games - it effectively stores a saved game every 2 seconds (or every 0.1 seconds if you're holding down space and running 20x faster), so it's a bit slow and can eat up huge amounts of memory Quote Link to comment Share on other sites More sharing options...
lexa Posted August 17, 2011 Author Report Share Posted August 17, 2011 Ok, great tips guys !Thanks Quote Link to comment Share on other sites More sharing options...
Pureon Posted August 17, 2011 Report Share Posted August 17, 2011 That too, though be careful in long games - it effectively stores a saved game every 2 seconds (or every 0.1 seconds if you're holding down space and running 20x faster), so it's a bit slow and can eat up huge amounts of memory Huh, i had no idea. I time-warp a lot. Quote Link to comment Share on other sites More sharing options...
lexa Posted August 23, 2011 Author Report Share Posted August 23, 2011 hey guysmaybe you could check it out, because the bot has beat me last time! it does not build strong warriors or machines yet, but still is very quick to build an army and attack :-o Quote Link to comment Share on other sites More sharing options...
lexa Posted August 23, 2011 Author Report Share Posted August 23, 2011 (edited) Here is the link to download the Split Bot alpha1 Edited August 23, 2011 by lexa Quote Link to comment Share on other sites More sharing options...
Pureon Posted August 23, 2011 Report Share Posted August 23, 2011 Hi lexa,I'm receiving the following error when attempting to run a match against Splitbot:<p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2102anonymous function does not always return a value</p><p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2138anonymous function does not always return a value</p><p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2149anonymous function does not always return a value</p><p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2189anonymous function does not always return a value</p><p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2205anonymous function does not always return a value</p><p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2236anonymous function does not always return a value</p><p class="warning">WARNING: JavaScript warning: simulation/ai/splitbot/SplitBot.js line 2246anonymous function does not always return a value</p><p class="error">ERROR: JavaScript error: simulation/ai/splitbot/SplitBot.js line 1ReferenceError: assignment to undeclared variable $estr @simulation/ai/splitbot/SplitBot.js:1</p><p class="error">ERROR: Failed to load script simulation/ai/splitbot/SplitBot.js</p>I've tried it with Alpha5, and the latest svn build. Hope you know what it could be - I want the bot to defeat me too Quote Link to comment Share on other sites More sharing options...
lexa Posted August 23, 2011 Author Report Share Posted August 23, 2011 HiThank you for the testThe warnings are ok, I'll check it later, it is due to javascript strict mode and I should fix each error by handThe error is a problem and I do not have this at home Can you try wirth the latest release of 0ad ? Quote Link to comment Share on other sites More sharing options...
Pureon Posted August 23, 2011 Report Share Posted August 23, 2011 Can you try wirth the latest release of 0ad ?I did, with the August 23rd build. All builds produce the same error for me (Windows).Have you tried running it on a clean svn build? Quote Link to comment Share on other sites More sharing options...
lexa Posted August 23, 2011 Author Report Share Posted August 23, 2011 Ok, I got it: something went wrong when I packaged the fileNow it is okSorry for this 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.