AI Ladder, 0.5 - Page 7

AI Ladder, 0.5

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: AI Ladder, v0.1

Post by AF »

That would be how to setup a client to run for the current setup you have.

What I want is to set it up then remove ALL internet connections, and runt he entire thing on a single machine. If I cannot do that, then I cannot call it a reliable test for the purposes of academia.

Either way I would focus on reducing the number of steps required to set this up for the purposes of gaining traction
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

AF wrote:Either way I would focus on reducing the number of steps required to set this up for the purposes of gaining traction
Yes, you are right... perhaps set up with default maps and stuff? By the way, by default, the following maps, mods and AIs are pre-configured:
- SmallDivide
- BA6.96
- HughAI v0.1, E323AI v2.12

Perhaps I can add some more default maps and mods, at least update to BA7.01? If you happen to have the hash for that, I'll add it into the static data.

Also, maybe worth adding AAI and so on?
What I want is to set it up then remove ALL internet connections, and runt he entire thing on a single machine. If I cannot do that, then I cannot call it a reliable test for the purposes of academia.
Ok, you can do that, but it's a little more work ;-)

You will need (prerequisites):
- a web server (tested with Apache2)
- python (tested with 2.3 and 2.6)
- web server should run .py and .cgi scripts in cgi
- python MySQLdb
- MySQL
- the name of a MySQL database, and a username and password

Procedure:
- grab the latest zip/tarball, unzip/untar
- webserver/db/createall.sh is a script that sets up your database
-- run ./createall.sh <username> <password> <database name> localhost
-- that should set up your tables, and populate them
- webserver/website is the website, so you can create a soft link to that from your website, or create a virtual directory in your website to point to it

Lastly, in the website directory, copy config.py.template to config.py, and enter the connection details for your database into it.

-> hopefully, cross fingers, you can open the website now, and configure it as you wish.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: AI Ladder, v0.1

Post by AF »

Could you not setup the database from python? Doing so would allow you to simply test for the database on the index page and redirect to a setup page, thus removing a handful of steps in the process and making things more flexible.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

Hmmm, that sounds like a good idea.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: AI Ladder, v0.1

Post by hoijui »

yeah.. it needs to get simpler altogether.

about auto downloading:
i would not like it if everyone with admin access to the website could download AIs/Maps and Mods to my machine (bot battle runner).
Maybe the battle runners(=calc engines) could assemble a list of all installed maps/mods/AIs, and send them to the website when connecting. on the website we could see on how many calc-engines a particular AI is on.
currently, best way is probably parsing ArchiveCacheV7.lua, or if that is too cumbersome, we probably have to think about using unitsync to fetch info about the isntalled spring.

i was running a calc-engine on my headless machine, a few days ago, scheduled a battle.. but it was still running after 3 hours or so, and i was not able to think of a good way to see what was going on.
I think i ran KAIk vs RAI, and wiht a test game on my other machine, under same conditions (same map, same AIs, same mod) it ended in 15 mins or so.

one minor thing: when scheduling a battle, and selecting an AI shortName, it shows all the AIs versions, not just hte selected ones.
definatly nothing that hurries :D
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: AI Ladder, v0.1

Post by aegis »

hoijui wrote:but it was still running after 3 hours or so, and i was not able to think of a good way to see what was going on.
trademark and I were working on a lua + flash dotwars.. could be used to view headless battles.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: AI Ladder, v0.1

Post by hoijui »

sounds perfect... can i use it already?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: AI Ladder, v0.1

Post by AF »

jquery + awk?
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

AF wrote:Could you not setup the database from python? Doing so would allow you to simply test for the database on the index page and redirect to a setup page, thus removing a handful of steps in the process and making things more flexible.
Done. Don't say I never listen to you AF :lol:

So, it should present a configuration page the first time you open the site, and then once it's created a configuration file, it will show you the main website from then on.

It detects whether it's been configured or not by the presence of either of config.py or config.pyc, so if you delete both of those files, you should see the configuration page (in latest version of git).

It needs the website directory to be writable to the webserver account, which I think is how most 'standard' things work, ie mediawiki, and so on?

@hoijui,
could assemble a list of all installed maps/mods/AIs, and send them to the website when connecting. on the website we could see on how many calc-engines a particular AI is on.
currently, best way is probably parsing ArchiveCacheV7.lua, or if that is too cumbersome, we probably have to think about using unitsync to fetch info about the isntalled spring
Ok, that's an interesting idea. I'll take a look. There's already commandline arguments to spring to get a list of ais I think? Perhaps that could be extended for maps and mods too? It'd need to output the maphash and the modhash as used in the startscript, to be useful.
but it was still running after 3 hours or so, and i was not able to think of a good way to see what was going on.
I can think of several possibilities off the top of my head:
- the AIs ground to a stalemate somehow
- the AIs both stalled somehow (lots of AIs do this under certain circumstances)
- the game finished, but you weren't using the BA mod, and the death message was different. Can you confirm which mod you were using? Was there anything interesting in the infolog.txt?

For the first two, really, the game should be timed out automatically by the bot runner. The code is already all over the place to do this (config values and stuff), but the timeout is not yet checked in the botrunner ;-) because I would have to check on Google for how to measure time in Python ;-) But if it is a problem right now I can implement this.

For the last one.... basically, if the mod issues a death message, we can make that message configurable per mod in the AILadder configuration, fairly easy. If the mod doesn't even issue a death message, there's not much that can be done without modifying spring or the mod ;-)

Edit: ps: can't you just look at the replay to see what happened?

Also, if we had a standardized source of entropy, it'd make it easy-peasy to replay exactly what happened, even without the actual replay! (see earlier post above, in this thread, search for entropy)
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

hoijui wrote: parsing ArchiveCacheV7.lua
That looks doable. How do I get the path in a platform-independent way?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: AI Ladder, v0.1

Post by hoijui »

hughperkins wrote:There's already commandline arguments to spring to get a list of ais I think? Perhaps that could be extended for maps and mods too? It'd need to output the maphash and the modhash as used in the startscript, to be useful.
I was thinking at exactly this as well. The thing is.. i could possibly add this.. but this really are things that unitsync is meant to be used for, not spring(.exe). unitsync alreayd has functions for all this.
In case you do not now what unitsync is:
It is a library used by all the lobbies ot get info abot the installed spring. traditionally it was hte list of units of a mod (or something like that), therefore the name. now it includes:
Mod list, Map list, AI list and more.
The thing is, this is a shared library, and as i have never used phyton, i dont know how hard it is to load and use it from there. If it is not very hard, this would probably best to use, as it already has all we have in a convenient form, and the path to unitsync is usually the same like the one to the spring executable (though some linux packages have it in a different location). in spirnglobby you need to set the two paths separately.
ArchiveCacheV7.lua should always be in the writeable data directory, but ... it may not be a good idea to use this, as it can contian outdated info, and only exists after runnig spring a first time.
about unitsync:
in spring source code, the main header is under tools/unitsync/unitsync_api.h

i used BA for testing, and. i think i never looked at infolog or the demo :D ;-)
will do that.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: AI Ladder, v0.1

Post by aegis »

oh, can't you just copy the replay and watch it without killing spring?
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

hoijui wrote:The thing is, this is a shared library, and as i have never used phyton, i dont know how hard it is to load and use it from there.
Ok, so, think 'loading java from spring' ;-)

Basically, you can call out from python into c, but, big but, you need to use something called SWIG, and SWIG is ... a lot of work. At least, I feel it is a lot of work, and I've done loads of SWIG before ( http://www.panda3d.org/phpbb2/viewtopic ... highlight= , one more of my never-to-be-used projects :lol: )

I feel it would be much simpler if there was either:
- a command-line front end to unitsync, could be quite a thin layer I feel?
- a command-line interface via spring

Maybe I can just throw together a command-line front end to unitsync, specific to AILadder? Do you have any code segments that could be useful?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: AI Ladder, v0.1

Post by hoijui »

i worked wiht SWING aswell, started with that for the Java interface stuff.. you dont have to tell me about it :D ;-) ugly stuff!
hughperkins wrote:Maybe I can just throw together a command-line front end to unitsync, specific to AILadder? Do you have any code segments that could be useful?
good idea!
dont have code segments that would be usefull really. maybe i am just not thinking on the right thing.. what did you think of?
ah yeah ...
when using unitsync, you first have to call some init method, and then yo ucan already querry for mods and maps. to querry for AIs, you first have to set a mod, if am not wrong, cause this way you will also get Lua AIs, and without setting the mod first, it may fail.

edit:
basically, you first querry numMods, then querry info for mod 0 till (numMods-1), and same for mods and AIs
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: AI Ladder, v0.1

Post by aegis »

oh hugh, I wrapped unitsync using pure python (ctypes) a while ago... it's not completely updated, but it should still work and includes a usage example

edit: just checked and it still works on current unitsync to parse maps/mods
it reads them into easy dictionaries... I'll add AI parsing and pastebin it.

edit: changed it to a parser and example script, pass it unitsync_api.h and it'll generate pure python bindings for it
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: AI Ladder, v0.1

Post by aegis »

...and here it is.
unitsync.py is the library, example.py is a usage example, and generate.py can generate unitsync.py from the unitsync_api.h header
Attachments
unitsync.zip
(4.64 KiB) Downloaded 17 times
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

Hey hoijui,

Just occurred to me: adding stuff in C++ to the bot runner makes the bot runner quite hard to package for lots of platforms.

I feel it's important that the bot runner is as easy to install and run and package as possible, since we probably want it to be able to run on as many machines as possible.

Maybe it might make it easier to install and run and package the bot runner if we obtained a list of maps and mods and so on through one of the other methods:
- obtain the path to the archivelist from spring ("spring --getarchivefilepath"?), and parse that
- get spring to tell us a list of maps and mods ("spring --list-available-maps", "spring --list-available-mods"?)

What do you think?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: AI Ladder, v0.1

Post by hoijui »

did you miss aegis posts? :D
the two right before yours.
He has a solution ready to use in phyton, to call unitsync.

edit: unitsync comes with every install of spring
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

hoijui wrote:did you miss aegis posts? :D
Yes. Checking those now!
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Re: AI Ladder, v0.1

Post by hughperkins »

aegis wrote:...and here it is.
unitsync.py is the library, example.py is a usage example, and generate.py can generate unitsync.py from the unitsync_api.h header
Woh :-O :shock: :o Sweeeettt! Excellent! Nice work!

I don't know how that works, but it ... just worked! I just ran "python example.py" and it told me. ... lots! Even the start positions on the maps!

So... to add this to AILadder... I just add generate.py and unitsync.py into the source somewhere (maybe in a sub-directory 'unitsync'), and then add stuff from 'example.py' into the bot runner?

Easy easy... cool! So, no need for any C++ stuff anywhere? Just works by the magic of Python .. .somehow?

Edit: by the way, can I just clarify: can I wack on a GPLv2 license header onto your code? What name do you want me to put in the copyright notice?
Post Reply

Return to “AI”