added multi-bot spinup
This commit is contained in:
parent
5f6ad59303
commit
5361cc276e
40
main.go
40
main.go
@ -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,20 +36,26 @@ func main() {
|
||||
gameName = flag.Arg(0)
|
||||
}
|
||||
// XXX: add TurnSpeed, WeaponDamage, WeaponSpeed
|
||||
r, err := NewRobot(
|
||||
*server,
|
||||
*port,
|
||||
gameName,
|
||||
*hp,
|
||||
*speed,
|
||||
*acceleration,
|
||||
*weaponRadius,
|
||||
*scannerRadius,
|
||||
*fireRate,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for i := 0; i < *botcount; i++ {
|
||||
r, err := NewRobot(
|
||||
*server,
|
||||
*port,
|
||||
gameName,
|
||||
*hp,
|
||||
*speed,
|
||||
*acceleration,
|
||||
*weaponRadius,
|
||||
*scannerRadius,
|
||||
*fireRate,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("my robot: %+v", r)
|
||||
go r.play()
|
||||
wg.Add(1)
|
||||
}
|
||||
log.Printf("%+v", r)
|
||||
r.play()
|
||||
wg.Wait()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user