package main import ( "flag" "log" "math/rand" "time" "bitbucket.org/hackerbots/client" ) var serverHostname = flag.String("server", "localhost", "server hostname") var port = flag.Int("port", 8666, "server port") var verbose = flag.Bool("verbose", false, "run verbosly") var forceJSON = flag.Bool("json", false, "force json encoding") func main() { log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) 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: "bspect", GameId: gameId, Verbose: *verbose, ForceJSON: *forceJSON, } var err error err = c.Negociate("spectator") if err != nil { log.Fatalf("%s: failed to negociate: %s", c.Name, err) } spectator := client.NewSimpleSpectator( c.Game.BoardSize.Width, c.Game.BoardSize.Height, ) c.Player = spectator go func() { if err := c.Play(); err != nil { log.Fatal(err) } }() spectator.Run() }