package main import ( "flag" "fmt" "math/rand" "os" "time" "hackerbots.us/client" "hackerbots.us/server" ) var serverHostname = flag.String("server", "localhost", "server hostname") var port = flag.Int("port", 8666, "server port") 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: "bspect", GameId: gameId, ForceJSON: *forceJSON, StateStream: make(chan *server.Boardstate), Die: make(chan struct{}), Player: client.Spectator{}, } var err error err = c.Negociate("spectator") 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() }