From 653a0b4bd2bea0e45e4e207f7d87de176e217881 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Sat, 10 Aug 2019 17:45:34 -0700 Subject: [PATCH] Converge Faster --- actors/snowball.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/actors/snowball.go b/actors/snowball.go index 0874588..9591540 100644 --- a/actors/snowball.go +++ b/actors/snowball.go @@ -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) }