From 62400c81db004e11e0f458f81b7206a6a4c179c7 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 24 Sep 2021 18:19:57 +0200 Subject: Randomization and y fixes --- pkg/pointer/pointer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/pointer/pointer.go') diff --git a/pkg/pointer/pointer.go b/pkg/pointer/pointer.go index 584a737..1465145 100644 --- a/pkg/pointer/pointer.go +++ b/pkg/pointer/pointer.go @@ -2,10 +2,13 @@ package pointer import ( "math/rand" + "time" "git.adyxax.org/adyxax/gofunge98/pkg/field" ) +var myRand = rand.New(rand.NewSource(time.Now().UnixNano())) + type InputFunction func() int type OutputFunction func(v int) @@ -87,7 +90,7 @@ func (p *Pointer) Redirect(c int) bool { p.dx, p.dy = -1, 0 case '?': directions := []int{0, -1, 1, 0, 0, 1, -1, 0} - r := 2 * rand.Intn(4) + r := 2 * myRand.Intn(4) p.dx, p.dy = directions[r], directions[r+1] case '[': p.dx, p.dy = p.dy, -p.dx -- cgit v1.2.3