diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-04 13:03:24 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:46 +0100 |
| commit | 358d872f7b6f36f341b5f001f93d2fafaf83c68e (patch) | |
| tree | 4a294ebebbce6aea0cc1b89e3a7686868942d037 | |
| parent | e13a0c10d627c10b52d0b0d694214cce8d1044e8 (diff) | |
| download | muhqs-game-358d872f7b6f36f341b5f001f93d2fafaf83c68e.tar.gz muhqs-game-358d872f7b6f36f341b5f001f93d2fafaf83c68e.zip | |
fix ai full action target selection
Only full actions with exactly one target were supported.
| -rw-r--r-- | go/game/ai.go | 11 |
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 } |
