aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/field.nim3
-rw-r--r--src/stack.nim16
-rw-r--r--src/stackStack.nim22
3 files changed, 39 insertions, 2 deletions
diff --git a/src/field.nim b/src/field.nim
index a9d706e..0a741c9 100644
--- a/src/field.nim
+++ b/src/field.nim
@@ -213,3 +213,6 @@ func Step*(f: Field, v: tuple[x, y: int], d: tuple[x, y: int]): (int, int) =
if not f.IsIn(x2, y2):
return (x, y)
x = x2; y = y2
+
+func GetSize*(f: Field): (int, int, int, int) =
+ return (f.x, f.y, f.lx, f.ly)
diff --git a/src/stack.nim b/src/stack.nim
index f08baf0..4565b5c 100644
--- a/src/stack.nim
+++ b/src/stack.nim
@@ -80,3 +80,19 @@ func Discard*(s: var Stack, n: int) =
func Next*(s: Stack): ref Stack =
return s.next
+
+func GetHeights*(s: Stack): seq[int] =
+ if s.next != nil:
+ result = s.next[].GetHeights()
+ result.add(s.height)
+ else:
+ return @[s.height]
+
+func YCommandPick*(s: var Stack, n, h: int) =
+ if n > s.height:
+ s.height = 1
+ s.data[0] = 0
+ else:
+ let v = s.data[s.height-n]
+ s.height = h
+ s.Push(v)
diff --git a/src/stackStack.nim b/src/stackStack.nim
index d55d5d9..b2bf29f 100644
--- a/src/stackStack.nim
+++ b/src/stackStack.nim
@@ -52,8 +52,7 @@ func End*(ss: var StackStack, v: var tuple[x, y: int]): bool =
let toss = ss.head
let soss = toss[].Next()
let n = toss[].Pop()
- v.y = soss[].Pop()
- v.x = soss[].Pop()
+ (v.x, v.y) = soss[].PopVector()
if n > 0:
soss[].Transfert(toss[], n)
else:
@@ -61,3 +60,22 @@ func End*(ss: var StackStack, v: var tuple[x, y: int]): bool =
dec ss.height
ss.head = soss
return false
+
+func Under*(ss: var StackStack): bool =
+ if ss.height == 1:
+ return true
+ let soss = ss.head[].Next()
+ let n = ss.Pop()
+ if n > 0:
+ for i in 0..<n:
+ ss.Push(soss[].Pop())
+ else:
+ for i in 0 ..< -n:
+ soss[].Push(ss.Pop())
+ return false
+
+func GetHeights*(ss: StackStack): (int, seq[int]) =
+ return (ss.height, ss.head[].GetHeights)
+
+func YCommandPick*(ss: var StackStack, n, h: int) =
+ ss.head[].YCommandPick(n, h)