Changes in Ai Training
Revision Differences of Revision 3
[TOC] ¶¶
## Genetic algorithm in widelands ¶
¶
Up to Build 19 (including) the AI was fully rule-based. Internally it used a lot of constants that had to be finetuned by hand - and that was time consuming for developer. So we are in process to switching to genetic algorithm where numerical constants are to be finetuned by random process (mutations) + and best mutations must be selected by a supervisor. The process is to be referred to as "AI training". ¶
¶
## How is AI DNA stored ¶
¶
The numbers used by DNA are stored in separate text files with suffix wai. So the training does not require recompilation only copying the files. There are two location for these files ¶
¶
* data dir - contains 4 wai files representing 4 individuals with slightly different DNA ¶
* home dir - can contain dumped DNAs from initialized DNA players. Those files tend to be unique, due to high "searching space". Depending also on Mutation rate. ¶
¶
## Training mode ¶
¶
While DNA is mutated (and unique DNA created) with each initialization of AI player, it is usually not dumped in home folder. So there is a command line switch "--ai_training" to activate it. It also increases mutation rate. ¶
Second usefull switch is "--auto_speed" that in realtime adjusts speed of game based on FPS to keep it around 14. The idea is to speed the game as much as possible without badly affecting AI. ¶
¶
## Is AI realy trained during the game? ¶
¶
No, no actual training neither learning is taking place. The learning here is just picking best AI from a group of randomly generated AIs, and copying it to data folder, so that could be used as a source for next game.... Can be done by human, or automated by script based on score or so... ¶
¶
## Content of wai files ¶
¶
The format of source and output wai files are exactly the same, when you open them you will see a 4 arrays of integers.