Converge Faster
This commit is contained in:
parent
8d91c2c06e
commit
653a0b4bd2
|
@ -1,9 +1,9 @@
|
||||||
package actors
|
package actors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.openprivacy.ca/sarah/microworlds/core"
|
"git.openprivacy.ca/sarah/microworlds/core"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Snowball struct {
|
type Snowball struct {
|
||||||
|
@ -19,7 +19,7 @@ func (sm *Snowball) Setup(env *core.Environment, t *core.Turtle) {
|
||||||
} else {
|
} else {
|
||||||
sm.color = 1
|
sm.color = 1
|
||||||
}
|
}
|
||||||
sm.sureness = 1
|
sm.sureness = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *Snowball) Run(env *core.Environment, t *core.Turtle) {
|
func (sm *Snowball) Run(env *core.Environment, t *core.Turtle) {
|
||||||
|
@ -27,9 +27,6 @@ func (sm *Snowball) Run(env *core.Environment, t *core.Turtle) {
|
||||||
am1 := t.Amount(env,1,"1")
|
am1 := t.Amount(env,1,"1")
|
||||||
am2 := t.Amount(env,1,"2")
|
am2 := t.Amount(env,1,"2")
|
||||||
|
|
||||||
t.Drop(env, 1, strconv.Itoa(sm.color))
|
|
||||||
|
|
||||||
|
|
||||||
if am1 > sm.sureness || am2 > sm.sureness {
|
if am1 > sm.sureness || am2 > sm.sureness {
|
||||||
if am1 > am2 {
|
if am1 > am2 {
|
||||||
if sm.color == 2 {
|
if sm.color == 2 {
|
||||||
|
@ -51,6 +48,11 @@ func (sm *Snowball) Run(env *core.Environment, t *core.Turtle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sm.sureness > 1 {
|
||||||
|
t.Drop(env, 1, strconv.Itoa(sm.color))
|
||||||
|
}
|
||||||
|
|
||||||
t.Step(env)
|
t.Step(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue