aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-24 18:19:57 +0200
committerJulien Dessaux2021-09-24 18:19:57 +0200
commit62400c81db004e11e0f458f81b7206a6a4c179c7 (patch)
tree986adcd2a4183d2adb4238d97909c9577f393d6b
parentFixed line feed handling which should be treated as like newline in Unefunge-... (diff)
downloadgofunge98-62400c81db004e11e0f458f81b7206a6a4c179c7.tar.gz
gofunge98-62400c81db004e11e0f458f81b7206a6a4c179c7.tar.bz2
gofunge98-62400c81db004e11e0f458f81b7206a6a4c179c7.zip
Randomization and y fixes
-rw-r--r--pkg/pointer/exec.go4
-rw-r--r--pkg/pointer/pointer.go5
2 files changed, 6 insertions, 3 deletions
diff --git a/pkg/pointer/exec.go b/pkg/pointer/exec.go
index 61b415f..f29b00b 100644
--- a/pkg/pointer/exec.go
+++ b/pkg/pointer/exec.go
@@ -230,8 +230,8 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
// 15
p.ss.head.Push(((now.Year() - 1900) * 256 * 256) + (int(now.Month()) * 256) + now.Day())
// 14
- p.ss.head.Push(lx + x)
- p.ss.head.Push(ly + y)
+ p.ss.head.Push(lx + x + 1)
+ p.ss.head.Push(ly + y + 1)
// 13
p.ss.head.Push(x)
p.ss.head.Push(y)
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