timplicit_auto.nim 403 B

12345678910111213141516171819
  1. # bug #1838
  2. type State = enum Empty, Tree, Fire
  3. const
  4. disp: array[State, string] = [" ", "\e[32m/\\\e[m", "\e[07;31m/\\\e[m"]
  5. proc univ(x, y: int): State = Tree
  6. var w, h = 30
  7. iterator fields(a = (0,0), b = (h-1,w-1)): auto =
  8. for y in max(a[0], 0) .. min(b[0], h-1):
  9. for x in max(a[1], 0) .. min(b[1], w-1):
  10. yield (y,x)
  11. for y,x in fields():
  12. doAssert disp[univ(x, y)] == disp[Tree]