added multi-bot spinup

This commit is contained in:
Stephen McQuay 2013-11-10 23:32:12 -08:00
parent 5f6ad59303
commit 5361cc276e

14
main.go
View File

@ -4,6 +4,7 @@ import (
"flag"
"log"
"math/rand"
"sync"
"time"
)
@ -21,11 +22,12 @@ var port = flag.Int("port", 8666, "server port")
var botname = flag.String("name", "gobot", "the name that other players will see")
var botcount = flag.Int("bots", 1, "number of bots to spin up")
var verbose = flag.Bool("verbose", false, "run verbosly")
func main() {
rand.Seed(time.Now().UnixNano())
var err error
var gameName string
flag.Parse()
if flag.NArg() < 1 {
@ -34,6 +36,9 @@ func main() {
gameName = flag.Arg(0)
}
// XXX: add TurnSpeed, WeaponDamage, WeaponSpeed
var wg sync.WaitGroup
for i := 0; i < *botcount; i++ {
r, err := NewRobot(
*server,
*port,
@ -48,6 +53,9 @@ func main() {
if err != nil {
log.Fatal(err)
}
log.Printf("%+v", r)
r.play()
log.Printf("my robot: %+v", r)
go r.play()
wg.Add(1)
}
wg.Wait()
}