Extract moveBot

This commit is contained in:
Luke Meyers 2020-02-05 19:32:53 -08:00
parent 33650b2e39
commit f91a975bf1
1 changed files with 23 additions and 22 deletions

25
game.go
View File

@ -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) {