Latest Posts

Topic: Make the AI independent from game speed

WorldSavior
Avatar
Topic Opener
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-01-02, 12:35

I was very surprised when I found out that the AI plays worse at highspeed. I always assumed that it can handle any game speed...

Probably it's not that easy to it train well if it cannot play correctly at the maximal speed of network games (which is 65.5)

If I understood it correctly, the AI checks often if something happened within a certain time - but not within the game time, but within real time. Isn't that just a mistake?


Wanted to save the world, then I got widetracked

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-01-02, 13:03

The bottom line is that AI's think() is (to be) called few times per second. But on higher speed the frequency drops to once in ~20 seconds (of gametime) or more. When called so rarely AI cannot function properly. F.e. it evaluates buildable fields and the calculated information is valid for 15 seconds (gametime). But AI is called 30 seconds (of gametime) later, so all info about buildable fields is expired then so it cannot build anything...

So point is that game pretends to run on high speed, but it is at the expense of AI (probably among other things)


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-01-04, 10:43

Does this has any impact using the option --auto_speed when --ai_training is used?

Edited: 2018-01-04, 10:44

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

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-01-04, 10:59

kaputtnik wrote:

Does this has any impact using the option --auto_speed when --ai_training is used?

I am not sure what exactly do you mean, but --auto_speed is just for this - to guess and keep reasonable maximum speed on which AI is still able to function normally


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-01-05, 12:29

The reason that it's implemented like that is to prevent dropping the FPS to the point that Widelands will freeze, because the AI is a bit resource hungry.

It was already implemented like that for Build 19.

Edited: 2018-01-05, 12:29

Busy indexing nil values

Top Quote
WorldSavior
Avatar
Topic Opener
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-01-05, 17:55

Tibor wrote:

The bottom line is that AI's think() is (to be) called few times per second. But on higher speed the frequency drops to once in ~20 seconds (of gametime) or more. When called so rarely AI cannot function properly. F.e. it evaluates buildable fields and the calculated information is valid for 15 seconds (gametime). But AI is called 30 seconds (of gametime) later, so all info about buildable fields is expired then so it cannot build anything...

Okay...

So point is that game pretends to run on high speed, but it is at the expense of AI (probably among other things)

Which other things? I think that the game runs fine at any speed, except for the AI...

GunChleoc wrote:

The reason that it's implemented like that is to prevent dropping the FPS to the point that Widelands will freeze, because the AI is a bit resource hungry.

It was already implemented like that for Build 19.

Okay, so that's why. What a pity...


Wanted to save the world, then I got widetracked

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-01-05, 20:34

WorldSavior wrote: Which other things? I think that the game runs fine at any speed, except for the AI...

I never investigated this seriously, but I know command queue is affected badly by big speed, its size grows... E.g. are you able to notice if animals are roaming properly at speed 100? Things like this might be affected..

Edited: 2018-01-05, 20:42

Top Quote
WorldSavior
Avatar
Topic Opener
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-01-08, 18:56

Tibor wrote:

WorldSavior wrote: Which other things? I think that the game runs fine at any speed, except for the AI...

I never investigated this seriously, but I know command queue is affected badly by big speed, its size grows... E.g. are you able to notice if animals are roaming properly at speed 100? Things like this might be affected..

Well, they move too fast, so I planned to watch at the replays. But somehow the replays of minimalistic test games of this kind don't work at all... (!)

So I made another test game where I actually built some game keeper huts, this made the replay work. There the animals looked normal.


Wanted to save the world, then I got widetracked

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-01-08, 20:01

WorldSavior wrote:

Tibor wrote:

WorldSavior wrote: Which other things? I think that the game runs fine at any speed, except for the AI...

I never investigated this seriously, but I know command queue is affected badly by big speed, its size grows... E.g. are you able to notice if animals are roaming properly at speed 100? Things like this might be affected..

Well, they move too fast, so I planned to watch at the replays. But somehow the replays of minimalistic test games of this kind don't work at all... (!)

So I made another test game where I actually built some game keeper huts, this made the replay work. There the animals looked normal.

I dont argue. But AI needs to be called at least once in 2 seconds of gameplay. And it is not at high speed. And this cannot be fixed from within AI.

EDIT: Roaming of animals is "state-less", each movement is independent of previous one, if the wait time between movements is 0.001 sec, or 0.2 sec, it does not matter for an animal...

Edited: 2018-01-08, 20:23

Top Quote
WorldSavior
Avatar
Topic Opener
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-01-10, 19:00

Okay


Wanted to save the world, then I got widetracked

Top Quote