Parameterize number of bots
This commit is contained in:
parent
891c2f435e
commit
d5f457ea91
17
main.go
17
main.go
|
@ -70,11 +70,15 @@ type state struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newState() state {
|
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{
|
return state{
|
||||||
bots: []bot{
|
bots: bots,
|
||||||
{pos: 0, active: true},
|
|
||||||
{pos: steps / 2},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,4 +124,7 @@ func won(b bot, s state) bool {
|
||||||
return b.pos == steps
|
return b.pos == steps
|
||||||
}
|
}
|
||||||
|
|
||||||
const steps = 150
|
const (
|
||||||
|
steps = 150
|
||||||
|
numBots = 5
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue