client/main.go

73 lines
1.8 KiB
Go
Raw Normal View History

package main
import (
"flag"
2013-11-10 23:37:43 -08:00
"fmt"
2014-01-06 23:33:06 -08:00
"log"
2013-09-20 11:16:11 -07:00
"math/rand"
2013-11-10 23:32:12 -08:00
"sync"
2013-09-28 13:10:25 -07:00
"time"
)
2013-10-19 00:30:20 -07:00
var hp = flag.Int("hp", 50, "")
2013-11-10 21:24:41 -08:00
var speed = flag.Int("speed", 50, "")
var acceleration = flag.Int("acceleration", 50, "")
2013-10-19 00:30:20 -07:00
var scannerRadius = flag.Int("srad", 50, "scanner radius")
2013-11-11 00:24:11 -08:00
var turnSpeed = flag.Int("omega", 50, "turn speed")
2013-10-19 00:30:20 -07:00
var fireRate = flag.Int("fire-rate", 50, "scanner radius")
2013-11-11 00:24:11 -08:00
var weaponRadius = flag.Int("wrad", 50, "weapon radius")
var weaponDamage = flag.Int("wdamage", 50, "weapons umph")
var weaponSpeed = flag.Int("wspeed", 50, "weapons speed")
2013-10-19 00:30:20 -07:00
2013-11-10 23:30:23 -08:00
// XXX: add TurnSpeed, WeaponDamage, WeaponSpeed
2014-01-10 01:22:33 -08:00
var server = flag.String("server", "localhost", "server hostname")
2013-09-27 00:04:25 -07:00
var port = flag.Int("port", 8666, "server port")
2013-11-10 23:30:23 -08:00
var botname = flag.String("name", "gobot", "the name that other players will see")
2013-11-10 23:32:12 -08:00
var botcount = flag.Int("bots", 1, "number of bots to spin up")
2013-11-10 23:30:23 -08:00
var verbose = flag.Bool("verbose", false, "run verbosly")
func main() {
2014-01-06 23:33:06 -08:00
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
2013-09-28 13:10:25 -07:00
rand.Seed(time.Now().UnixNano())
2013-11-10 23:30:23 -08:00
var gameName string
flag.Parse()
if flag.NArg() < 1 {
2013-11-10 23:30:23 -08:00
gameName = "debug"
} else {
2013-11-10 23:30:23 -08:00
gameName = flag.Arg(0)
}
2013-11-10 23:32:12 -08:00
var wg sync.WaitGroup
2013-11-10 23:32:12 -08:00
for i := 0; i < *botcount; i++ {
r := &robot{
server: *server,
port: *port,
name: fmt.Sprintf("%s%d", *botname, i),
game: GameParam{
name: gameName,
},
// XXX: update with missing fields
stats: StatsRequest{
Hp: *hp,
Speed: *speed,
Acceleration: *acceleration,
ScannerRadius: *scannerRadius,
2013-11-11 00:24:11 -08:00
TurnSpeed: *turnSpeed,
FireRate: *fireRate,
2013-11-11 00:24:11 -08:00
WeaponRadius: *weaponRadius,
WeaponDamage: *weaponDamage,
WeaponSpeed: *weaponSpeed,
},
2014-01-10 01:22:33 -08:00
wg: &wg,
knownObstacles: make(map[string]Obstacle),
2013-11-10 23:32:12 -08:00
}
wg.Add(1)
2013-11-11 00:25:28 -08:00
go r.play()
}
2013-11-10 23:32:12 -08:00
wg.Wait()
}