Extract moveBot
This commit is contained in:
parent
33650b2e39
commit
f91a975bf1
25
game.go
25
game.go
|
@ -65,8 +65,20 @@ func updateState(sOld state) state {
|
|||
s := sOld
|
||||
|
||||
for i, t := range s.teams {
|
||||
b := t.baton.holder
|
||||
moveBot(t.baton.holder)
|
||||
maybePassBaton(&s.teams[i])
|
||||
}
|
||||
|
||||
for _, t := range s.teams {
|
||||
if won(*t.baton.holder, s) {
|
||||
s.gameOver = true
|
||||
}
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func moveBot(b *bot) {
|
||||
if b.a == 0 {
|
||||
b.a = 1
|
||||
}
|
||||
|
@ -86,17 +98,6 @@ func updateState(sOld state) state {
|
|||
b.v = -maxV
|
||||
}
|
||||
b.pos += b.v
|
||||
|
||||
maybePassBaton(&s.teams[i])
|
||||
}
|
||||
|
||||
for _, t := range s.teams {
|
||||
if won(*t.baton.holder, s) {
|
||||
s.gameOver = true
|
||||
}
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func maybePassBaton(t *team) {
|
||||
|
|
Loading…
Reference in New Issue