diff --git a/main.go b/main.go index 09f88b3..d110c71 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "log" "math/rand" "net/http" + "time" ) var hp = flag.Int("hp", 150, "") @@ -184,6 +185,7 @@ func negociate(ws *websocket.Conn, gameid string) (i *infos, err error) { } func main() { + rand.Seed(time.Now().UnixNano()) var err error var gameid string flag.Parse() @@ -234,16 +236,16 @@ func main() { break } } - log.Printf("%+v: %+v", me.Position, moveto) if govector.Distance(me.Position, moveto) < 3.0 { + log.Printf("old: %+v: %+v", me.Position, moveto) moveto = govector.Point2d{ X: rand.Float64() * board_info.width, Y: rand.Float64() * board_info.height, } + log.Printf("new: %+v: %+v", me.Position, moveto) } // TODO: send instructions - log.Printf("%+v: %+v", me.Position, moveto) err = websocket.JSON.Send(ws, Instruction{ MoveTo: &moveto, })