package main import ( "flag" "fmt" "math/rand" "os" "time" "hackerbots.us/client" "hackerbots.us/server" ) var hp = flag.Int("hp", 50, "") var speed = flag.Int("speed", 50, "") var acceleration = flag.Int("acceleration", 50, "") var scannerRadius = flag.Int("srad", 50, "scanner radius") var turnSpeed = flag.Int("omega", 50, "turn speed") var fireRate = flag.Int("fire-rate", 50, "scanner radius") var weaponRadius = flag.Int("wrad", 50, "weapon radius") var weaponDamage = flag.Int("wdamage", 50, "weapons umph") var weaponSpeed = flag.Int("wspeed", 50, "weapons speed") // XXX: add TurnSpeed, WeaponDamage, WeaponSpeed var serverHostname = flag.String("server", "localhost", "server hostname") var port = flag.Int("port", 8666, "server port") var botname = flag.String("name", "gobot", "the name that other players will see") var forceJSON = flag.Bool("json", false, "force json encoding") func main() { rand.Seed(time.Now().UnixNano()) var gameId string flag.Parse() if flag.NArg() < 1 { gameId = "debug" } else { gameId = flag.Arg(0) } c := &client.Client{ Server: *serverHostname, Port: *port, Name: *botname, GameId: gameId, // XXX: update with missing fields StatsReq: server.StatsRequest{ Hp: *hp, Speed: *speed, Acceleration: *acceleration, ScannerRadius: *scannerRadius, TurnSpeed: *turnSpeed, FireRate: *fireRate, WeaponRadius: *weaponRadius, WeaponDamage: *weaponDamage, WeaponSpeed: *weaponSpeed, }, ForceJSON: *forceJSON, StateStream: make(chan *server.Boardstate), Die: make(chan struct{}), Player: client.NewSimplePlayer(800, 600), } var err error err = c.Negotiate("robot") if err != nil { fmt.Fprintf(os.Stderr, "%s: failed to negociate: %s\n", c.Name, err) os.Exit(1) } go func() { if err := c.Play(); err != nil { close(c.Die) } }() c.Visualize() }