diff --git a/core/environment_test.go b/core/environment_test.go index 01c2933..fad9f4e 100644 --- a/core/environment_test.go +++ b/core/environment_test.go @@ -7,7 +7,7 @@ import ( func TestEnvironment_Mark(t *testing.T) { env := NewEnvironment(3,3) env.Mark(1,1,9) - env.Evaporate() + env.Evaporate(0.9) for x:=0;x<3;x++ { for y:=0;y<3;y++ { t.Logf("mark(%d,%d) = %f", x,y,env.Sniff(x,y)) @@ -15,7 +15,7 @@ func TestEnvironment_Mark(t *testing.T) { } t.Logf("\n") - env.Evaporate() + env.Evaporate(0.9) for x:=0;x<3;x++ { for y:=0;y<3;y++ { t.Logf("mark(%d,%d) = %f", x,y,env.Sniff(x,y)) diff --git a/core/turtle.go b/core/turtle.go index e9c1de2..e309cc7 100644 --- a/core/turtle.go +++ b/core/turtle.go @@ -11,6 +11,16 @@ type Turtle struct { } +type NilActor struct { + +} + +func (NilActor) Setup(*Environment, *Turtle) { +} + +func (NilActor) Run(*Environment, *Turtle) { +} + func NewTurtle(env *Environment, actor Actor) *Turtle { for { turtle := new(Turtle) @@ -35,7 +45,7 @@ var headings = [][]int{{-1,-1},{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0}} func (t *Turtle) setRandomHeading() { - t.heading = rand.Intn(7) + t.heading = rand.Intn(8) } func (t *Turtle) SetXY(x,y int) { @@ -82,7 +92,7 @@ func (t *Turtle) FollowGradient(env *Environment, distance int, threshold float3 y := (t.ypos + dy) - h1 := (t.heading+1) % 7 + h1 := (t.heading+1) % 8 dx1 := headings[h1][0] * distance dy1 := headings[h1][1] * distance diff --git a/core/turtle_test.go b/core/turtle_test.go index 5838b2e..7712eef 100644 --- a/core/turtle_test.go +++ b/core/turtle_test.go @@ -5,7 +5,7 @@ import ( ) func TestTurtle_Wiggle(t *testing.T) { - turtle := NewTurtle(NewEnvironment(3,3,)) + turtle := NewTurtle(NewEnvironment(3,3,), new(NilActor)) counts := []int{0,0,0,0,0,0,0,0} for i:=0;i<1000;i++ { turtle.Wiggle()