Topic: auto_speed problem
Tibor Topic Opener |
Posted at: 2021-12-05, 16:48
I noticed the behaviour of game has changed. If I set very high speed, fps are OK, but AI does not work... In the past, FPS were good indicator how much CPU time AI gets, but no more. I can run AI training at fixes speed, like 3x, but this is waste of the time. Any ideas? EDIT: In fact, I can imagine AI training without UI, or with UI with extra low priority... Edited: 2021-12-05, 16:59
![]() ![]() |
Nordfriese![]() |
Posted at: 2021-12-05, 17:22
Widelands is multithreaded in current master now. FPS now only indicates how responsive the UI thread is, but AI is managed by the logic thread. hessenfarmer is currently working on giving the AI a thread of its own. After this refactoring we could consider how to make auto_speed useful again ![]() ![]() |
hessenfarmer![]() |
Posted at: 2021-12-05, 17:23
This is due to the fact that the ui is now running in an own thread whiuch means fps is no valid measure anymore. Edit: I just had a look and I think moving the auto_speed function into the AI code and using the schedule delay as a measure should work Edited: 2021-12-05, 17:41
![]() ![]() |
Tibor Topic Opener |
Posted at: 2021-12-05, 17:43
This is generally good news! AI now presumes that is it called twice a second, see here: In my opinion, up to 1 second frequency is bearable, but I would not go beyond. If you know the code of game scheduler - do you see even at least dirty hack for to make the game regulate the speed to keep the frequency below 1000 ms per one think() of each player? Generally I need 100 hours for meaningful training, if I set the speed to 3, it might mean 2x-3x more time, this is simply too much... EDIT: based on my long ago investigation AI was called each 0.1 second, and as the code above shows it just "skipped" the turn if too early after last execution. Edited: 2021-12-05, 17:45
![]() ![]() |
hessenfarmer![]() |
Posted at: 2021-12-05, 17:43
As my knowledge seems to be too limited to get this done, I'd rather go the other way round and maybe postpone the threading of AI. ![]() ![]() |
hessenfarmer![]() |
Posted at: 2021-12-05, 18:28
ok my branch is compiling locally. if it succeeds I'll push it on Github. Let's keep fingers crossed after some attempts it compiled and it is working. https://github.com/widelands/widelands/pull/5149 Edited: 2021-12-05, 19:59
![]() ![]() |
Tibor Topic Opener |
Posted at: 2021-12-05, 20:14
I will test the branch, I will have some feedback tomorrow probably Do you want to merge it into Master? ![]() ![]() |
hessenfarmer![]() |
Posted at: 2021-12-05, 20:27
yes after I got a positive review. ![]() ![]() |
Tibor Topic Opener |
Posted at: 2021-12-05, 20:55
Where can I see actual speed - I do not see it on the default screen. ![]() ![]() |
Tibor Topic Opener |
Posted at: 2021-12-05, 21:00
Also game().is_auto_speed() was broken before, and I am not sure if it works now... ![]() ![]() |