seed prng, be less verbose
This commit is contained in:
parent
535d5ac445
commit
bc92c2e01f
6
main.go
6
main.go
@ -10,6 +10,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hp = flag.Int("hp", 150, "")
|
var hp = flag.Int("hp", 150, "")
|
||||||
@ -184,6 +185,7 @@ func negociate(ws *websocket.Conn, gameid string) (i *infos, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
var err error
|
var err error
|
||||||
var gameid string
|
var gameid string
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -234,16 +236,16 @@ func main() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("%+v: %+v", me.Position, moveto)
|
|
||||||
if govector.Distance(me.Position, moveto) < 3.0 {
|
if govector.Distance(me.Position, moveto) < 3.0 {
|
||||||
|
log.Printf("old: %+v: %+v", me.Position, moveto)
|
||||||
moveto = govector.Point2d{
|
moveto = govector.Point2d{
|
||||||
X: rand.Float64() * board_info.width,
|
X: rand.Float64() * board_info.width,
|
||||||
Y: rand.Float64() * board_info.height,
|
Y: rand.Float64() * board_info.height,
|
||||||
}
|
}
|
||||||
|
log.Printf("new: %+v: %+v", me.Position, moveto)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: send instructions
|
// TODO: send instructions
|
||||||
log.Printf("%+v: %+v", me.Position, moveto)
|
|
||||||
err = websocket.JSON.Send(ws, Instruction{
|
err = websocket.JSON.Send(ws, Instruction{
|
||||||
MoveTo: &moveto,
|
MoveTo: &moveto,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user