renamed to randomDirection to reflect what function does
This commit is contained in:
parent
4d0eac703c
commit
5b438b7ffe
12
robot.go
12
robot.go
@ -196,7 +196,7 @@ func (r *robot) recon() {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *robot) selectDirection() *govector.Point2d {
|
||||
func (r *robot) randomDirection() *govector.Point2d {
|
||||
p := govector.Vector2d{
|
||||
X: rand.Float32() * r.game.BoardSize.Width,
|
||||
Y: rand.Float32() * r.game.BoardSize.Height,
|
||||
@ -223,14 +223,14 @@ func (r *robot) navigate() {
|
||||
if r.boardstate.Reset {
|
||||
// XXX We actually *want* to get here, but never do ..
|
||||
panic("reset")
|
||||
r.moveto = r.selectDirection()
|
||||
r.moveto = r.randomDirection()
|
||||
}
|
||||
|
||||
if r.moveto == nil {
|
||||
if *verbose {
|
||||
log.Printf("%s: nil", r.name)
|
||||
}
|
||||
r.moveto = r.selectDirection()
|
||||
r.moveto = r.randomDirection()
|
||||
}
|
||||
|
||||
togo := r.me.Position.Sub(*r.moveto).Mag()
|
||||
@ -238,7 +238,7 @@ func (r *robot) navigate() {
|
||||
if *verbose {
|
||||
log.Printf("%s got to destination", r.name)
|
||||
}
|
||||
r.moveto = r.selectDirection()
|
||||
r.moveto = r.randomDirection()
|
||||
return
|
||||
}
|
||||
if !r.probe(r.me.Position.Add(r.me.Heading.Scale(safeDistance))) {
|
||||
@ -250,7 +250,7 @@ func (r *robot) navigate() {
|
||||
if *verbose {
|
||||
log.Printf("%s unsafe to move, choose new direction", r.name)
|
||||
}
|
||||
r.moveto = r.selectDirection()
|
||||
r.moveto = r.randomDirection()
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -259,7 +259,7 @@ func (r *robot) navigate() {
|
||||
if *verbose {
|
||||
log.Printf("%s apparent collision", r.name)
|
||||
}
|
||||
r.moveto = r.selectDirection()
|
||||
r.moveto = r.randomDirection()
|
||||
r.speed = 0
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user