Currently Online

Latest Posts

Topic: News about AI

Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 1954
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2017-08-06, 11:24

I´ll have plenty of time the next couple of weeks and as I offered some weeks ago, I can spend some of it training the AI. Just to make sure I understand it correctly – AI training works like this:

  • Watch a local multiplayer game with AIs only

  • Decide which player performed best

  • Find his individual DNA file in ~/.widelands/ai and find out which parents DNA this is derived from

  • Copy-paste it over the primary parent DNA in data/ai

Or did I misunderstand something?

You also mentioned an aitrainingmode which has to be switched on – how does that work? (The files in ~/.widelands/ai are not created for me at the moment. I think the creation of these files should be turned on/off by a command-line option which should be specified in the --help listing, defaulted to off. By the way, compiling the frisian branch which uses the trunk AI from bzr8410 works fine on my Linux computer.)


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-08-06, 12:42

Nordfriese wrote:

  • Find his individual DNA file in ~/.widelands/ai and find out which parents DNA this is derived from

Well such linkage is not needed. I usually run 4 games concurrently and winner of first map goes to first position and so on..

You also mentioned an aitrainingmode which has to be switched on – how does that work? (The files in ~/.widelands/ai are not created for me at the moment. I think the creation of these files should be turned on/off by a command-line option which should be specified in the --help listing, defaulted to off. By the way, compiling the frisian branch which uses the trunk AI from bzr8410 works fine on my Linux computer.)

Training mode has 3 effects:

  • autoadjustment of game speed - which makes playing as human player very annoying or flatly impossible
  • re-initialization of DNA after savegame load
  • dumping wai files into home folder

Sedond and third bullet are activated here:

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/ai/ai_help_structs.h#L122

and first bullet here:

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/wui/interactive_base.cc#L60


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-08-06, 12:45

kaputtnik wrote:

Should be new AI files generated only in aitrainingmode mode, or always?

I think this depends on how the AI is learning. Can you explain what the new generated AI files in ~/-widelands/ai are used for and what the difference is in regard to the shipped files?

Note that when you play 100 games with 300 AI opponents in total, all of them will have unique DNA (try a diff on generated wai files). So somebody should take the best one and copy the generated file into one of 4 "source" wai files. No training is done automatically


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 1954
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2017-08-06, 19:45

I trained AI for one round now. The losing AIs were very weak, many got deadlocked (no logs/foresters, no granite/marblemines, no spiderfarm/spidercloth…). In two out of four games I considered the only AI that wasn´t deadlocked after some time the winner. In the other two games, one AI grew surprisingly strong and easily outproduced and defeated its enemies. These AIs are already much stronger than the AI of build19, and can even become a serious challenge for experienced players. Great work! face-smile.png

An observation: Barbarians always without exception enhanced all their metal workshops very quickly, so they soon ran out of tools and never built a new metal workshop. Could this be an issue with general rules about enhancing and basic economy, not with training?

What should I do now with the winning DNA files? Is there a branch to upload them to, or should I keep them on my local disk until I trained the AI many more times?


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-08-06, 20:50

Let me use the word ROUND. So you did one round of testing and have 4 winners. You copied them to 4 source files to be used for next round, correct?

Now you will pick different map and do another round of testing/training and promote 4 winners to source files.

And you repeat such rounds basically forever - with different maps...

When doing automated training, I (script in fact) pick 4 winners from 60 players. 60 players for manual training is too much probably, but dont go very deep below this number, though there is no exact minimal limit...

As for enhancement, this is probably hardcoded, but I would need to investigate. This can be one of points for next AI branch.

As for results of your training, it is too soon create new branch and merge to trunk, but it is trivial to share your AI files if anybody is interested.

Also there is something like mutation rate - I plan to decrease it bit before release....

EDIT:

I am off for next week, so I hope everything is clear enough..

Edited: 2017-08-06, 22:54

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 19:48
Posts: 2440
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-08-07, 06:55

Tibor wrote:

kaputtnik wrote:

Should be new AI files generated only in aitrainingmode mode, or always?

I think this depends on how the AI is learning. Can you explain what the new generated AI files in ~/-widelands/ai are used for and what the difference is in regard to the shipped files?

Note that when you play 100 games with 300 AI opponents in total, all of them will have unique DNA (try a diff on generated wai files). So somebody should take the best one and copy the generated file into one of 4 "source" wai files. No training is done automatically

So 'AI Learning' is done automatically, but getting the stuff the AI has learned into the game is done by a human (one has to copy the files from his home folder into the data folder).

I think the files should then be created only in aitrainingmode with a commandline switch. Otherwise the folder .widelands/ai/ get spammed with files which are useless for a 'normal' player. Maybe adding a text file in there, describing what this folder is used for. Something like:

"This folder is used when using the command line switch 'aitrainingmode'. If you are interested in training the ai, see the wiki page at https://wl.widelands.org/wiki/Ai Traininghttps://wl.widelands.org/wiki/ai training"


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2017-08-08, 11:00

Nordfriese wrote:

You also mentioned an aitrainingmode which has to be switched on – how does that work? (The files in ~/.widelands/ai are not created for me at the moment. I think the creation of these files should be turned on/off by a command-line option which should be specified in the --help listing, defaulted to off. By the way, compiling the frisian branch which uses the trunk AI from bzr8410 works fine on my Linux computer.)

Yes, we definitely want a command line option for this and have plans to implement one in another follow-up branch.


Busy indexing nil values

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-08-12, 17:00

kaputtnik wrote:

So 'AI Learning' is done automatically, but getting the stuff the AI has learned into the game is done by a human (one has to copy the files from his home folder into the data folder).

Almost 100% exact. You are right about copying the files...

But frankly 'learning' is not the best word. New AI is generated on initialization and save to the file. The file is not updated afterwards so technically no learning is taking place. We just pick one of multiple unique DNAs that seems to perform the best.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-08-12, 17:03

@Nordfriese

I am back now and I can resume the training. I need your files to continue from them. Did you have time for more than one round?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 1954
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2017-08-12, 17:22

I had one round every day since I started face-smile.png sometimes two rounds a day face-grin.png

In every round, I watched 10-20 games with 6-16 players each until I had selected 4 outstanding AIs. Every round had maps in the categories quick fights, seafaring, long games and difficult terrain (so AI can be flexible). In every round, every winning AI was noticeably better than the winners of the previous round.

Here are the files


Top Quote