aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-30 14:52:13 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:32 +0200
commit3e070cedf2455cb7513c0200512f2105fa2f1871 (patch)
treedfec977cc3291b663587b51c3d282d049b331db1
parent294b1260d3f7b15437cbc802295f2f36a86bd409 (diff)
downloadmuhqs-game-3e070cedf2455cb7513c0200512f2105fa2f1871.tar.gz
muhqs-game-3e070cedf2455cb7513c0200512f2105fa2f1871.zip
fix SimpleAi unit handling
Remove finished unit AIs. Skip Units with only street actions left.
-rw-r--r--go/game/ai.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/go/game/ai.go b/go/game/ai.go
index f630b41b..928285bc 100644
--- a/go/game/ai.go
+++ b/go/game/ai.go
@@ -652,7 +652,13 @@ func (ai *SimpleAiControl) handlePriority() Action {
// Slow Actions
if s.stack.IsEmpty() {
for _, u := range s.OwnUnits(ai.p) {
- if len(u.AvailSlowActions()) == 0 {
+ as := u.AvailSlowActions()
+ if len(as) == 0 {
+ delete(ai.uAis, u)
+ continue
+ } else if _, ok := as[0].(*StreetAction); ok && len(as) == 1 {
+ // FIXME: Support Street Actions
+ delete(ai.uAis, u)
continue
}
@@ -667,6 +673,8 @@ func (ai *SimpleAiControl) handlePriority() Action {
if !more {
// Consume all available actions to not consider the unit this term again.
u.tap()
+ // Delete unitAI if it finished its turn
+ delete(ai.uAis, u)
continue
}
if a == nil && more {