e-dt 4 years ago
parent
commit
a8d342c958
  1. 18
      main.py

18
main.py

@ -18,7 +18,7 @@ class GridSquare:
def __repr__(self):
return str(self)
def makeGrid(height, width):
def makeGrid():
return [[GridSquare(SquareType.AISLE, None) for x in range(0,width)] for y in range(0,height)]
class Passenger:
@ -48,18 +48,19 @@ def nextSquare(passenger, grid):
def GenPassList():
border = [Passenger((0, a),(-1,-1)) for a in range(0,3)]
for x in range(1,width):
border.append([Passenger((x, a),(-1,-1)) for a in range(0,3)])
border.append([Passenger((x, a),(-1,-1)) for a in range(4,7)])
border += [Passenger((x, a),(-1,-1)) for a in range(0,3)]
border += [Passenger((x, a),(-1,-1)) for a in range(4,7)]
return border
grid=makeGrid()
#boarding order
passengers = GenPassList()
for index, i in enumerate(passengers):
grid[i.curr[0]][i.curr[1]] = index
toad = 0
def tick():
global toad
# print grid
for row in grid:
for guy in row:
@ -70,12 +71,15 @@ def tick():
else:
print(" ", end="")
print()
if toad < len(passengers):
grid[passengers[toad].curr[0]][passengers[toad].curr[1]].occupant = toad #added
toad += 1
for (i, man) in enumerate(passengers):
#im sexist
cp = man.curr
man.curr = nextSquare(man, grid)
grid[cp[0]][cp[1]] = None #they move out of there
grid[man.curr[0]][man.curr[1]] = i
grid[cp[0]][cp[1]].occupant = None #they move out of there
grid[man.curr[0]][man.curr[1]].occupant = i
def run():
while 1:

Loading…
Cancel
Save