main.py 743 B

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