diff --git a/main.py b/main.py index a859fea..3bf77bd 100644 --- a/main.py +++ b/main.py @@ -36,7 +36,7 @@ def manhattanDistance(pos1, pos2): def mooreNeighbourhood(pos): return [i for i in [(pos[0], pos[1]+1), (pos[0]+1, pos[1]), (pos[0]-1, pos[1]), (pos[0], pos[1]-1)] if - i[0] >= 0 and i[1] >= 0 and i[0] < width and i[1] < height] + i[0] >= 0 and i[1] >= 0 and i[0] < height and i[1] < width] def nextSquare(passenger, grid): #simple behaviour for now @@ -58,7 +58,7 @@ def GenPassList(grid): border += [Passenger((a, x),(-1,-1)) for a in range(0,3)] for a in range(0,3): grid[a][x].typ = SquareType.SEAT - border += [Passenger((a, x),(-1,-1)) for a in range(4,7)] + border += reversed([Passenger((a, x),(-1,-1)) for a in range(4,7)]) for a in range(4,7): grid[a][x].typ = SquareType.SEAT return border @@ -70,7 +70,9 @@ passengers = GenPassList(grid) toad = 0 + def tick(): + done=True global toad # print grid for row in grid: @@ -92,11 +94,14 @@ def tick(): continue if man.curr == (-1, -1): continue + done=False #im sexist cp = man.curr man.curr = nextSquare(man, grid) grid[cp[0]][cp[1]].occupant = None #they move out of there grid[man.curr[0]][man.curr[1]].occupant = i + if done: + exit() def run(): while 1: