about summary refs log tree commit diff stats
path: root/fe
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2022-10-08 00:17:20 +0000
committerelioat <elioat@tilde.institute>2022-10-08 00:17:20 +0000
commitedc101e80bfb932bba7a8c4f063e6b84a910c45b (patch)
treeb5b27c7b485d3df945bc8505ad87cbf9ab11005f /fe
parent843db0701933f5899f9de17be409a4167f99b078 (diff)
downloadtour-edc101e80bfb932bba7a8c4f063e6b84a910c45b.tar.gz
*
Diffstat (limited to 'fe')
-rw-r--r--fe/parade.fe66
1 files changed, 66 insertions, 0 deletions
diff --git a/fe/parade.fe b/fe/parade.fe
new file mode 100644
index 0000000..d52b43a
--- /dev/null
+++ b/fe/parade.fe
@@ -0,0 +1,66 @@
+; A simple game engine, based on https://wiki.xxiivv.com/site/parade.html
+; Primitives: CREATE, PROGRAM, USE, LOOK
+; DATA: the world is a stack.
+
+(= push
+    (mac (val lst)
+        (list '= lst (list 'cons val lst))))
+
+(= for
+    (mac (item lst . body)
+        (list 'do
+            (list 'let 'for-iter lst)
+            (list 'while 'for-iter
+                (list 'let item '(car for-iter))
+            '(= for-iter (cdr for-iter))
+            (cons 'do body)))))
+
+(= create
+    (fn (new-obj)
+        (push (cons new-obj nil) world)
+        world))
+
+(= put
+    (fn (to-put pair)
+    	(do
+            (setcdr pair to-put)
+        pair)))
+
+(= program
+    (fn (target utility)
+        (for x world
+            (if (is  (car x) target) (put utility x)
+                (not (car x) target) nil))))
+
+(= all-of-creation
+    (fn (lst)
+        (print ">  Behold, all of creation!")
+        (for x lst
+           (print "> " x))))
+
+(= look
+    (fn (target)
+        (for x world
+            (if (is  (car x) target) (print ">  looking at" (car x) "reveals" (cdr x)))
+                (not (car x) target) nil)))
+
+
+
+(let world ())
+(create "banana")
+(create "kiwi")
+(create "apple")
+(create "tango")
+(program "apple" "bath")
+(program "tango" "dance")
+(program "kiwi" "shoe")
+(program "banana" "peel")
+
+(all-of-creation world)
+
+(print "")
+
+(look "apple")
+(look "tango")
+(look "kiwi")
+(look "banana")