Converge Faster

This commit is contained in:
Sarah Jamie Lewis 2019-08-10 17:45:34 -07:00
parent 8d91c2c06e
commit 653a0b4bd2
1 changed files with 9 additions and 7 deletions

View File

@ -1,9 +1,9 @@
package actors
import (
"git.openprivacy.ca/sarah/microworlds/core"
"math/rand"
"strconv"
"git.openprivacy.ca/sarah/microworlds/core"
"math/rand"
"strconv"
)
type Snowball struct {
@ -19,7 +19,7 @@ func (sm *Snowball) Setup(env *core.Environment, t *core.Turtle) {
} else {
sm.color = 1
}
sm.sureness = 1
sm.sureness = 2
}
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")
am2 := t.Amount(env,1,"2")
t.Drop(env, 1, strconv.Itoa(sm.color))
if am1 > sm.sureness || am2 > sm.sureness {
if am1 > am2 {
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)
}