aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-04 13:03:24 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:46:39 +0200
commitdec4514160011f9856b926f2485e0aa6e2d318bc (patch)
tree679b4aafd36d48ab7a36305ca8b13771935e3380
parentb0c607108cc340faf2699904b584f018a2106bda (diff)
downloadmuhqs-game-dec4514160011f9856b926f2485e0aa6e2d318bc.tar.gz
muhqs-game-dec4514160011f9856b926f2485e0aa6e2d318bc.zip
fix ai full action target selection
Only full actions with exactly one target were supported.
-rw-r--r--go/game/ai.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/go/game/ai.go b/go/game/ai.go
index 38823257..ac6fb29a 100644
--- a/go/game/ai.go
+++ b/go/game/ai.go
@@ -277,11 +277,14 @@ out:
}
a := fullActions[idx]
- options := a.Targets().NextOptions()
- if len(options) > 1 {
- idx = ai.s.Rand.Intn(len(options) - 1)
+ for options := a.Targets().NextOptions(); options != nil; options = a.Targets().NextOptions() {
+ idx = 0
+ if len(options) > 1 {
+ idx = ai.s.Rand.Intn(len(options) - 1)
+ }
+ a.Targets().AddTarget(options[idx])
}
- a.Targets().AddTarget(options[idx])
+
ai.actions <- a
}