annotate code/dotScanner.lm @ 26:4f7a421e77c6

Tag teaming the continuation function
author William Morgan <billjunk@mrgn.org>
date Fri, 25 Jul 2014 23:19:29 -0700
parents ec0b74f4f2d9
children 75c97fb80602
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
1 #{
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
2 length <- :lst {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
3 len <- []
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
4 while: { not: (lst isInteger?)} do: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
5 lst <- lst tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
6 len <- len + 1
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
7 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
8 len
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
9 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
10
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
11 reverse <- :lst {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
12 new <- []
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
13 while: { not: (lst isInteger?)} do: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
14 new <- (lst value) | new
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
15 lst <- lst tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
16 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
17 new
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
18 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
19
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
20 split:at <- :lst :pos {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
21 first <- []
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
22 i <- 0
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
23 while: { i < pos } do: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
24 first <- (lst value) | first
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
25 lst <- lst tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
26 i <- i + 1
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
27 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
28 #[(reverse: first) lst]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
29 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
30
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
31 map <- :lst fun {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
32 new <- []
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
33 while: { not: (lst isInteger?) } do: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
34 new <- (fun: (lst value)) | new
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
35 lst <- lst tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
36 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
37 reverse: new
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
38 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
39
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
40 fold:with <- :lst acc :fun {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
41 while: { not: (lst isInteger?) } do: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
42 acc <- fun: acc (lst value)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
43 lst <- lst tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
44 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
45 acc
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
46 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
47
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
48 filter <- :lst pred {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
49 new <- []
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
50 while: { not: (lst isInteger?) } do: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
51 if: (pred: (lst value)) {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
52 new <- (lst value) | new
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
53 } else: {}
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
54 lst <- lst tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
55 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
56 reverse: new
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
57 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
58
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
59 makeTree:size <- :lst :size {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
60 ret <- 0
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
61 sub <- 0
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
62 half <- size / 2
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
63 if: size = 2 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
64 ret <- #[(lst value) ((lst tail) value)]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
65 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
66 if: size = 1 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
67 ret <- lst
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
68 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
69 sub <- split: lst at: half
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
70 ret <- #[
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
71 (makeTree: (sub value) size: half)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
72 (makeTree: (sub tail) size: size-half)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
73 ]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
74 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
75 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
76 ret
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
77 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
78
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
79 makeTree <- :lst {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
80 size <- lst length
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
81 #[size (makeTree: lst size: size)]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
82 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
83
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
84 get:fromTree:size <- :idx :tree :size {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
85 print: #[1 tree size]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
86 ret <- 0
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
87 half <- size / 2
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
88 if: size <= 2 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
89 if: idx = 0 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
90 ret <- tree value
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
91 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
92 ret <- tree tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
93 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
94 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
95 if: idx < half {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
96 ret <- get: idx fromTree: (tree value) size: half
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
97 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
98 ret <- get: idx-half fromTree: (tree tail) size: size-half
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
99 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
100 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
101 ret
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
102 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
103
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
104 get:fromTree <- :idx :tree {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
105 size <- tree value
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
106 print: #[0 size]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
107 get: idx fromTree: (tree tail) size: size
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
108 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
109
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
110 treeMap:size <- :tree fun :size {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
111 ret <- 0
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
112 half <- size / 2
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
113 if: size = 2 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
114 ret <- #[(fun: (tree value)) (fun: (tree tail))]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
115 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
116 if: size = 1 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
117 ret <- #[(fun: (tree value)) 0]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
118 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
119 ret <- #[
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
120 (treeMap: (tree value) fun size: half)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
121 (treeMap: (tree tail) fun size: size-half)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
122 ]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
123 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
124 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
125 ret
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
126 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
127
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
128 treeMap <- :tree fun {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
129 #[(tree value) (treeMap: (tree tail) fun size: (tree value))]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
130 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
131
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
132 tree:size:update:with <- :tree :size :idx :fun {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
133 ret <- 0
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
134 half <- size / 2
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
135 if: size = 2 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
136 if: idx = 0 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
137 ret <- #[(fun: (tree value)) (tree tail)]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
138 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
139 ret <- #[(tree value) (fun: (tree tail))]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
140 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
141 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
142 if: size = 1 {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
143 ret <- #[(fun: (tree value)) 0]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
144 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
145 if: (idx < half) {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
146 ret <- #[
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
147 (tree: (tree value) size: half update: idx with: fun)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
148 (tree tail)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
149 ]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
150 } else: {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
151 ret <- #[
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
152 (tree value)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
153 (tree: (tree tail) size: size-half update: idx-half with: fun)
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
154 ]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
155 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
156 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
157 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
158 ret
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
159 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
160
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
161 tree:update:with <- :tree :idx :fun {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
162 #[(tree value) (tree: (tree tail) size: (tree value) update: idx with: fun)]
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
163 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
164
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
165 tree:set:to <- :tree :idx :val {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
166 tree: tree update: idx with: :el { val }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
167 }
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
168
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
169 grid:get <- :grid :pos {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
170 x <- pos value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
171 y <- pos tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
172 get: x fromTree: (get: y fromTree: grid)
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
173 }
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
174
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
175 grid:update:with <- :grid :pos :fun {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
176 x <- pos value
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
177 y <- pos tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
178 tree: grid update: y with: :row {
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
179 tree: row update: x with: fun
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
180 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
181 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
182
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
183 grid:set:to <- :grid :pos :val {
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
184 grid: grid update: pos with: :el { val }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
185 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
186
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
187 grid:inBounds? <- :grid :pos {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
188 x <- pos value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
189 y <- pos tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
190 maxY <- grid value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
191 maxX <- (get: 0 fromTree: grid) value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
192 ((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
193 }
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
194
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
195 /*
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
196 ListGet <- :cell idx {
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
197 if: idx = 0 {cell value} else: {
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
198 ListGet: (cell tail) (idx - 1)
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
199 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
200 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
201 TupGet <- :cell depth size {
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
202 if: idx = 0 {cell value} else: {
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
203 if: size = 1 {cell tail} else: { // warning, out-of-bounds idx will return a value!
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
204 TupGet: (cell tail) (idx - 1) (size - 1)
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
205 }}
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
206 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
207
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
208 // rowmajor lists
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
209 GridGet <- :x y w h{
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
210 ListGet
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
211 ...
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
212 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
213 */
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
214
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
215 visited <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
216 /*
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
217 advancer <- :listOfTupsLams {
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
218 notdone <- 1
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
219 while: { notdone } do: {
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
220 listOfLamTups <- fold: listOfLamTups [] with: :acc el{
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
221 ret <- 0
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
222 newTupLams <- (el tail):
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
223
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
224
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
225 // zero means "I have not found it"
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
226
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
227 if: (el value) = 0 {
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
228 newTupLams <- (el tail):
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
229 if: (isInteger?: newTupLams) {
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
230 ret <- acc
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
231 } else: {
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
232 ret <- acc | newTupLams
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
233 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
234 } else: {
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
235 notdone <- 0
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
236 ret <- [(el tail)]
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
237 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
238 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
239 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
240
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
241 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
242 */
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
243
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
244 calcPos <- :move from {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
245 x <- from value
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
246 y <- from tail
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
247 if: move {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
248 if: move = 1 {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
249 x <- x + 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
250 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
251 if: move = 2 {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
252 y <- y + 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
253 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
254 x <- x - 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
255 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
256 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
257 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
258 y <- y - 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
259 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
260 #[x y]
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
261 }
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
262
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
263 makeContClos <- :grid myLoc path {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
264 {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
265 ret <- []
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
266 move <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
267 atpos <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
268 if: (grid: grid inBounds?: myLoc) {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
269 if: (grid: visited get: myLoc) {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
270 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
271 atpos <- grid: grid get: myLoc
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
272 if: (atpos = 2) + (atpos = 3) + (atpos = 4) {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
273 ret <- #[1 (reverse: path)]
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
274 } else: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
275 visited <- grid: visited set: myLoc to: 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
276 if: atpos {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
277 move <- 0
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
278 while: { move < 4 } do: {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
279 ret <- (makeContClos: grid (calcPos: move myLoc) move | path) | ret
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
280 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
281 ret <- #[0 ret]
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
282 } else: {}
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
283 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
284 }
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
285 } else: {}
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
286 ret
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
287 }
24
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
288 }
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
289
37158acf31e5 Initial pass at scan loop
William Morgan <billjunk@mrgn.org>
parents: 12
diff changeset
290 //scanFor <- :target visited {
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
291 //}
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
292 counterLoad <- 4
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
293 step <- :myState world {
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
294 grid <- makeTree: (map: (world value) :row { makeTree: row })
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
295 lmState <- (world value) tail
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
296 myLoc <- (lmState tail) value
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
297
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
298
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
299 visited <- treeMap: grid :el { 0 }
26
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
300 /*
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
301 cont <- {
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
302 if: (grid: grid get: myLoc
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
303 visited <- tree: visited set: myLoc to: 1
4f7a421e77c6 Tag teaming the continuation function
William Morgan <billjunk@mrgn.org>
parents: 25
diff changeset
304 */
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
305
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
306
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
307
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
308 //myPos <-
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
309 path <- [3 1 3 1] //scanFor: 2 3 [myPos]
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
310 move <- myState value
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
311 counter <- (myState tail) - 1
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
312 if: counter = 0 {
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
313 move <- move + 1
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
314 counter <- counterLoad
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
315 if: move = 4 {
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
316 move <- 0
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
317 } else: {}
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
318 } else: {}
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
319 #[0 ((path tail) value)]
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
320 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
321
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
322 main <- :initWorld mystery {
23
5ded24518dc5 Add library functions from mike00.lm to dotScanner.lm. Add some code to process map state into a "grid" structure and make a version for visited state.
Michael Pavone <pavone@retrodev.com>
parents: 12
diff changeset
323 #[0 step]
12
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
324 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
325 }
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
326
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
327 //does not work:
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
328 //someListOrTup get: 0
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
329 //lambdaman program (step function) faulted TagMismatch
1c6d4f2642d0 Fist progress toward a simple recursive dot scanner bot
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
330