From d5f457ea91e8e5f80b3cee06d9f953c445d24799 Mon Sep 17 00:00:00 2001 From: Luke Meyers Date: Tue, 4 Feb 2020 23:46:43 -0800 Subject: [PATCH] Parameterize number of bots --- main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 583d886..3fd485c 100644 --- a/main.go +++ b/main.go @@ -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 +)