aboutsummaryrefslogtreecommitdiff
path: root/go/game/state.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-12-27 16:51:24 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:13 +0200
commitd29bdcd1eca581af24b236a4529e7d67956aedb8 (patch)
treed28ae93b3a41f8a90045ba4def491ce19a8fcbc9 /go/game/state.go
parent5779c8439848a1d42204b30f6bb3c422ca7c6b86 (diff)
downloadmuhqs-game-d29bdcd1eca581af24b236a4529e7d67956aedb8.tar.gz
muhqs-game-d29bdcd1eca581af24b236a4529e7d67956aedb8.zip
finish the target-oriented ai
Fix path selection choosing a to big step, since the next step was determined by the moving range and not the actually available movement tiles. Fix generating a target for the AI by introducing a dummy action to support "enemy" target constraints.
Diffstat (limited to 'go/game/state.go')
-rw-r--r--go/game/state.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/go/game/state.go b/go/game/state.go
index 577a0cb8..734bddd2 100644
--- a/go/game/state.go
+++ b/go/game/state.go
@@ -17,7 +17,7 @@ type State interface {
Players() []*Player
PlayerByName(name string) *Player
PlayerById(id int) *Player
- AddNewPlayer(name string, deck *Deck, color color.Color)
+ AddNewPlayer(name string, deck *Deck, color color.Color) *Player
AddNewAiPlayer(name string, color color.Color)
ActivePlayer() *Player
ActivePhase() PhaseType
@@ -110,9 +110,10 @@ func NewLocalState() *LocalState {
return s
}
-func (s *LocalState) AddNewPlayer(name string, deck *Deck, color color.Color) {
+func (s *LocalState) AddNewPlayer(name string, deck *Deck, color color.Color) *Player {
p := NewPlayer(len(s.players)+1, name, deck, s, color)
s.players = append(s.players, p)
+ return s.players[len(s.players)-1]
}
func (s *LocalState) AddNewAiPlayer(name string, color color.Color) {