Using machinelearning to build an AI question

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Arag
Engineer
Engineer
Posts: 2
Joined: 29 May 2013 13:38

Using machinelearning to build an AI question

Post by Arag »

For my master thesis I'm working on using a technique called dynamic scripting to create an AI capable of playing openttd. Part of the technique is generating AI's and then testing how well they perform against others. To do this I need to run (a lot) of games with just AI players and at as high a speed as possible. Preferably I would be able to use another program that I'll write myself to start openttd and load all the generated AI's and store the gamestate in some way at the end. I was wondering if people here could give me some tips on how to do that.

I've looked around at the documentation and I saw that you can start the game from the command line, is there any way to start a game with several AI's purely from the command line? I saw that this was possible for a dedicated server, but you can't increase the game speed on those, right? And is it possible for gamescripts or AI's to write to files?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Using machinelearning to build an AI question

Post by Zuu »

Arag wrote:I've looked around at the documentation and I saw that you can start the game from the command line, is there any way to start a game with several AI's purely from the command line?
Have a look at the scripts in the scripts folder of an OpenTTD installation. These are not Game Scripts, but an older type of scripts. The name of each script indicate when it run. Inside the script you can put the same commands as you can execute in the in-game console.

One of these scripts isgame_start.scr. Try insert "start_ai MyAI" in there for the number of rows that you need. It is also possible to assign AI parameters as additional arguments to the start_ai command. My best guess is that if you have an AI parameter that in info.nut is named "my_parameter", then you will pass it as

Code: Select all

start_ai MyAI my_parameter=1
However, that may not be exactly the correct syntax. Check the help for the start_ai command or the source code if the help is insufficient.

Arag wrote:And is it possible for gamescripts or AI's to write to files?
No, not by default. However if OpenTTD run in Linux or if you convert the Windows version to a console program, you can pipe the debug output to a file. If you know some C++ and compile OpenTTD yourself, it is possible to do additional things only limited by the effort you want to spend.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Maninthebox
Engineer
Engineer
Posts: 113
Joined: 08 Aug 2008 11:35
Contact:

Re: Using machinelearning to build an AI question

Post by Maninthebox »

Hi Arag,

I'm a researcher at the Delft University of Technology from the parallel and distributed systems group. Within that group we have a group that focusses on gaming and one of the games we do research with is actually OpenTTD. Our (heavily adapted) version of OpenTTD runs a 10 year game with 15 AIs in roughly 3.5 minute (on my normal desktop machine; we use our DAS-4 supercomputer for running many tests in parallel) and then automatically generates a bunch of graphs. See below for an example:
all_10_year_competition_score.png
all_10_year_competition_score.png (14.76 KiB) Viewed 632 times
(The fact that I show a picture in which my own AI has the highest score is purely accidental of course ;) )

If you happen to live in the Netherlands: come and visit our group and we'll help you get started :) If not: drop me an e-mail and we'll go from there. I think I should be able to isolate the parts from our tree that would help you and make a patch out of that. We have made changes for launching games with a selection of AI's directly from the command-line and we have chances (mostly an adapted video driver) to make it run as fast as possible.
Arag
Engineer
Engineer
Posts: 2
Joined: 29 May 2013 13:38

Re: Using machinelearning to build an AI question

Post by Arag »

Thanks for your replies Zuu and Maninthebox! I think I should be able to go from here.
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: Using machinelearning to build an AI question

Post by Steffl »

Hi.

You could use the -c flag to load game settings from a config-file. You can start openttd the normal way and set the game settings and the competitors you want. Then you quit the game so the settings are getting written to the config file. Then you better copy it, so you don't change it accidentially.
In Linux you find the default config file in "/homedirectory/.openttd/openttd.cfg".
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 12 guests