Parameterize number of bots

This commit is contained in:
Luke Meyers 2020-02-04 23:46:43 -08:00
parent 891c2f435e
commit d5f457ea91
1 changed files with 12 additions and 5 deletions

17
main.go
View File

@ -70,11 +70,15 @@ type state struct {
}
func newState() state {
var bots []bot
for i := 0; i < numBots; i++ {
bots = append(bots, bot{pos: i * (steps / numBots)})
}
bots[0].active = true
return state{
bots: []bot{
{pos: 0, active: true},
{pos: steps / 2},
},
bots: bots,
}
}
@ -120,4 +124,7 @@ func won(b bot, s state) bool {
return b.pos == steps
}
const steps = 150
const (
steps = 150
numBots = 5
)