Hi,
Can an AI perform I/O on files while running?
SummerBulb
Can an AI read/write files?
Moderator: OpenTTD Developers
Re: Can an AI read/write files?
If you for development reasons want to output data to a file that is possible with a bit of work.
In non-windows you just run OpenTTD with high enough debug level for the ai category so that AILog message come out at stdout/stderr and then save that to a file. In windows you need to either convert openttd.exe to a console application or make some modifications and compile your own custom build for that.
Add a start and stop flag for the data you want to export and use a script / sed / grep that look for this flag in the log file to extract the data you are interested in.
In non-windows you just run OpenTTD with high enough debug level for the ai category so that AILog message come out at stdout/stderr and then save that to a file. In windows you need to either convert openttd.exe to a console application or make some modifications and compile your own custom build for that.
Add a start and stop flag for the data you want to export and use a script / sed / grep that look for this flag in the log file to extract the data you are interested in.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
-
- Engineer
- Posts: 24
- Joined: 06 Feb 2010 22:12
Re: Can an AI read/write files?
Is there a reason why save text files is disabled?
Having that possibilty will be of great use.
SummerBulb
Having that possibilty will be of great use.
SummerBulb
Re: Can an AI read/write files?
You can read any Squirrel File, and Squirrel has a syntax similar to ECMa so you can define data using nearly JSON.
You can't write in files, but you can write in savedgames by implementing Save and Load function in yout AIController. This would be enough for most of the cases. But, writing in text files may not be in the philosophy of NoAI. Would it be good that an AI behaviour depends on something else than the game and a random source ?
You can't write in files, but you can write in savedgames by implementing Save and Load function in yout AIController. This would be enough for most of the cases. But, writing in text files may not be in the philosophy of NoAI. Would it be good that an AI behaviour depends on something else than the game and a random source ?
Re: Can an AI read/write files?
For development purpose such as some kind of evolution or learning it is fully possible to work around the restriction. You can export data via the log and then you can import data by modifying the nut files. Write a helper script/program that reads the logs and put the data into a nut file that the AI can read when you load a save game or start a new game etc.
The restriction is there so that you can't store things between different games.
The restriction is there so that you can't store things between different games.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 5 guests