From bc92c2e01f4c9aee506ad307493bf5906042ba5e Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Sat, 28 Sep 2013 13:10:25 -0700 Subject: [PATCH] seed prng, be less verbose --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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, })