From 358d872f7b6f36f341b5f001f93d2fafaf83c68e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 4 Feb 2023 13:03:24 +0100 Subject: fix ai full action target selection Only full actions with exactly one target were supported. --- go/game/ai.go | 11 +++++++---- 1 file 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 } -- cgit v1.2.3