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 addr = flag.String("addr", "ws://localhost:8666", "server hostname") var botname = flag.String("name", "gobot", "the name that other players will see") var forceJSON = flag.Bool("json", false, "force json encoding") var botType = flag.String("bot", "simple", "which Bot [fraserbot, simple]") 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: *addr, Name: *botname, GameId: gameId, ForceJSON: *forceJSON, } sr := server.StatsRequest{ Hp: *hp, Speed: *speed, Acceleration: *acceleration, ScannerRadius: *scannerRadius, TurnSpeed: *turnSpeed, FireRate: *fireRate, WeaponRadius: *weaponRadius, WeaponDamage: *weaponDamage, WeaponSpeed: *weaponSpeed, } switch *botType { case "simple": c.Player = client.NewSimplePlayer(800, 600, sr) case "fraserbot": c.Player = client.NewFraserbot("Fraserbot") default: fmt.Fprintf(os.Stderr, "must specify a known bot \n") os.Exit(1) } var err error err = c.Negotiate("robot", c.Player) if err != nil { fmt.Fprintf(os.Stderr, "%s: failed to negociate: %s\n", c.Name, err) os.Exit(1) } if err := c.Play(); err != nil { fmt.Fprintf(os.Stderr, "problem during play: %v\n", err) os.Exit(1) } }