Browse Source

playing around

Kyle Perik 8 months ago
parent
commit
3f3c39c68d
4 changed files with 60 additions and 17 deletions
  1. 12 6
      main.py
  2. 13 0
      step-bread-2.judo
  3. 11 0
      step-bread.judo
  4. 24 11
      step.judo

+ 12 - 6
main.py

@@ -2,23 +2,29 @@ from judo.run import compile_program, run_prototype
2 2
 from termfun import start, draw
3 3
 
4 4
 initial_state = {
5
-    'hydration': 0,
6
-    'flour': 0,
7
-    'water': 0,
8
-    'starter': 0,
9
-    'total': 100,
5
+    'x': 0,
6
+    'y': 0,
7
+    'ox': 5,
8
+    'oy': 5,
9
+    'c': 0,
10 10
 }
11 11
 
12 12
 judo_step = compile_program(open('step.judo').read().splitlines())
13 13
 
14 14
 def step(s, c):
15
-    return run_prototype(*judo_step, dict(s))
15
+    return run_prototype(*judo_step, dict(s, c=ord(c)))
16 16
 
17 17
 def render(s):
18
+    draw(int(s['x']), int(s['y']), '@')
19
+    draw(int(s['ox']), int(s['oy']), '@', 1)
20
+    draw(0, 5, f'c = {s["c"]}')
21
+
22
+def render_bread(s):
18 23
     draw(0, 0, f'hydration = {s["hydration"]}')
19 24
     draw(0, 1, f'flour = {s["flour"]}')
20 25
     draw(0, 2, f'water = {s["water"]}')
21 26
     draw(0, 3, f'starter = {s["starter"]}')
22 27
     draw(0, 4, f'total = {s["total"]}')
28
+    draw(0, 5, f'c = {s["c"]}')
23 29
 
24 30
 start(initial_state, step, render)

+ 13 - 0
step-bread-2.judo

@@ -0,0 +1,13 @@
1
+hydration * 100 = args.hydration * 100 + (0 if c - 119 else 1) + (0 if c - 115 else (0 - 1))
2
+flour + water + starter = total
3
+starter = total / 10
4
+water + starter / 2 = hydration * total
5
+total = args.total + ((0 if c - 100 else 1) + (0 if c - 97 else (0 - 1))) * 100
6
+c = args.c
7
+
8
+c | out
9
+hydration | out
10
+flour | out
11
+water | out
12
+starter | out
13
+total | out

+ 11 - 0
step-bread.judo

@@ -0,0 +1,11 @@
1
+hydration = 40 / 100
2
+flour + water + starter = total
3
+starter = total / 10
4
+water + starter / 2 = hydration * total
5
+total = args.total + 100
6
+
7
+hydration | out
8
+flour | out
9
+water | out
10
+starter | out
11
+total | out

+ 24 - 11
step.judo

@@ -1,11 +1,24 @@
1
-hydration = 40 / 100
2
-flour + water + starter = total
3
-starter = total / 10
4
-water + starter / 2 = hydration * total
5
-total = args.total + 100
6
-
7
-hydration | out
8
-flour | out
9
-water | out
10
-starter | out
11
-total | out
1
+walk = :[
2
+    x = (0 if (right) else 1) + (0 if (left) else (0 - 1))
3
+    y = (0 if (down) else 1) + (0 if (up) else (0 - 1))
4
+]
5
+
6
+move = walk~[
7
+    left = c - 97
8
+    right = c - 100
9
+    down = c - 115
10
+    up = c - 119
11
+]
12
+x = args.x + move.x
13
+y = args.y + move.y
14
+
15
+ox = args.ox - (args.ox - x) / 10
16
+oy = args.oy - (args.oy - y) / 10
17
+
18
+c = args.c
19
+
20
+x | out
21
+y | out
22
+ox | out
23
+oy | out
24
+c | out