1
0
Fork 0
microworlds/actors/woodchips.go

38 lines
621 B
Go
Raw Normal View History

2019-08-03 02:00:33 +00:00
package actors
import (
"git.openprivacy.ca/sarah/microworlds/core"
)
type WoodChips struct {
SniffDistance int
Carrying bool
}
func (a * WoodChips) Setup(env *core.Environment, t *core.Turtle) {
//t.SetXY(150,150)
}
func (a*WoodChips) Run(env *core.Environment, t *core.Turtle) {
if a.Carrying {
if env.HasValue(t.Pos()) {
for {
t.Wiggle()
t.Step(env)
if !env.HasValue(t.Pos()){
env.PutValue(t.Pos())
a.Carrying = false
break
}
}
}
} else {
if env.HasValue(t.Pos()) {
env.TakeValue(t.Pos())
a.Carrying = true
t.TurnAround()
}
}
t.Wiggle()
t.Step(env)
}