refactor, add second obstacle

This commit is contained in:
Luke Meyers 2020-02-05 20:41:23 -08:00
parent e727d74e78
commit 1220b0db23
2 changed files with 8 additions and 1 deletions

View File

@ -35,6 +35,10 @@ func NewState() State {
Lane: 0,
Pos: Steps / 3,
},
{
Lane: 1,
Pos: Steps * 2 / 3,
},
},
}
}
@ -66,6 +70,7 @@ func UpdateState(sOld State) State {
s := sOld
for i, t := range s.Teams {
accelerate(t.Baton.Holder)
moveBot(t.Baton.Holder, sOld)
maybePassBaton(&s.Teams[i])
}

View File

@ -2,7 +2,7 @@ package game
import "math/rand"
func moveBot(b *Bot, s State) {
func accelerate(b *Bot) {
if b.a == 0 {
b.a = 1
}
@ -21,7 +21,9 @@ func moveBot(b *Bot, s State) {
if b.v < -maxV {
b.v = -maxV
}
}
func moveBot(b *Bot, s State) {
for i := 0; i < b.v; i++ {
if !collide(b.id, b.Pos+1, b.Lane, s) {
b.Pos++