Randomization and y fixes

This commit is contained in:
Julien Dessaux 2021-09-24 18:19:57 +02:00
parent 2895308807
commit 62400c81db
2 changed files with 6 additions and 3 deletions

View file

@ -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