# =============================================================================
"""MAZE : animate walker in a maze"""
# ==============================================================================
__author__  = "Christophe Schlick modified by Philippe Blasi
__version__ = "0.0" # skeleton version
__date__    = "2022-11-12"
# ==============================================================================
from ezTK import *
from ezCLI import read_csv # helper function to parse CSV files
# ------------------------------------------------------------------------------
def main(index:int=0):
  """create the main window and pack the widgets"""
  global win
  maze, walk = read_files(index) # read content of data files
  rows, cols = 12, 12 # set maze size (should be computed from variable 'maze')
  # ----------------------------------------------------------------------------
  win = Win(title=f"MAZE : {cols}x{rows}", op=4, grow=False) # put size on title
  step = 32 # set step size (should be computed from maze size and screen size)
  win.canvas = Canvas(win, width=step*cols, height=step*rows)
  # ----------------------------------------------------------------------------
  # TODO (draw maze on Canvas using 'create_rectangle' for each cell)
  # ----------------------------------------------------------------------------
  win.after(500, tick); win.loop()
# ------------------------------------------------------------------------------
def read_files(index:int) -> (list,list):
  """return content of data files (maze file + walk file) for given index"""
  # TODO (read maze from "mazeN.csv" and walk from 'walkN.csv', where N=index)
  mazefile, walkfile = 'TODO', 'TODO'
  maze = [] # 'maze' must be a list of lists of chars (one char per maze cell)
  walk = [] # 'walk' must be a list of integer pairs (two coords per walk step)
  return maze, walk
# ------------------------------------------------------------------------------
def tick() -> None:
  """update walker position on canvas"""
  # TODO (get next walker position and move walker on canvas)
# ==============================================================================
if __name__ == '__main__':
  main(1) # show maze and animate walker for the given maze index
# ==============================================================================
