EntelectChallenge / 2022-Arctica

8 stars 11 forks source link

Wrong return in action processing causes engine to stop processing all actions #23

Closed kobus-v-schoor closed 2 years ago

kobus-v-schoor commented 2 years ago

In the following loop there is a return statement that, when triggered, causes the engine to altogether stop processing commands from all bots. This can be triggered when a bot sends two units to build on the same node, but when the second unit starts building the node is no longer available, causing worldStateService.GetNode to return null. The return on line 315 then triggers, and the rest of the actions don't get processed, leading to units never being returned to the available pool of units and eventual widespread deaths.

https://github.com/EntelectChallenge/2022-Arctica/blob/25308962439f385c02e04489d3607fff34c54a62/game-engine/Engine/Services/EngineService.cs#L298-L316

The action must first be partially processed (even if invalid) so that the units get returned to the available pool, and then removed.

kobus-v-schoor commented 2 years ago

Actually, now that I look at it looks like just replacing the return with a continue should do the trick, since if the actions are not added to independentPlayerActions or groupedPlayerActions they don't get executed, but the action will still get removed in the loop foreach (var playerAction in actionsToComplete) - I'll update my existing PR with the fix

kobus-v-schoor commented 2 years ago

Hi, I see this issue is still present in the latest release - just a heads up to fix it.

https://github.com/EntelectChallenge/2022-Arctica/blob/c89853cf67274b0dc005c84d2f86b04ff72e2455/game-engine/Engine/Services/EngineService.cs#L312-L316

kobus-v-schoor commented 2 years ago

Fixed in release https://github.com/EntelectChallenge/2022-Arctica/releases/tag/2022.3.1