Browse Source

YEAHgit pull

master
e-dt 3 years ago
parent
commit
7680f48542
  1. 26
      main.py

26
main.py

@ -2,6 +2,7 @@
#(height, width) #(height, width)
import random as rnd import random as rnd
from enum import Enum from enum import Enum
import time
class SquareType(Enum): class SquareType(Enum):
AISLE = 0 AISLE = 0
@ -72,9 +73,16 @@ grid=makeGrid()
#boarding order #boarding order
passengers = GenPassList(grid) passengers = GenPassList(grid)
import random
random.seed(505)
random.shuffle(passengers)
toad = 0 toad = 0
import os
def nunty(x):
if x is None: return -1
return x
def tick(): def tick():
done=True done=True
global toad global toad
@ -82,14 +90,15 @@ def tick():
for row in grid: for row in grid:
for guy in row: for guy in row:
if guy.occupant is not None: if guy.occupant is not None:
print("X", end="") print(chr(0x4e00 + guy.occupant), end="")
elif guy.typ == SquareType.SEAT: elif guy.typ == SquareType.SEAT:
print("_", end="") print("", end="")
else: else:
print(".", end="") print("", end="")
print() print()
print("---") print("---")
if toad < len(passengers): print(grid[3][0].occupant, grid[3][1].occupant, passengers[nunty(grid[3][1].occupant)].dest)
if toad < len(passengers) and grid[3][0].occupant is None:
grid[3][0].occupant = toad #added grid[3][0].occupant = toad #added
passengers[toad].curr = (3, 0) passengers[toad].curr = (3, 0)
toad += 1 toad += 1
@ -98,12 +107,19 @@ def tick():
continue continue
if man.curr == (-1, -1): if man.curr == (-1, -1):
continue continue
if i == 36:
print(nextSquare(man, grid))
done=False done=False
#im sexist #im sexist
cp = man.curr cp = man.curr
man.curr = nextSquare(man, grid) man.curr = nextSquare(man, grid)
grid[cp[0]][cp[1]].occupant = None #they move out of there other = grid[cp[0]][cp[1]]
other.occupant = grid[man.curr[0]][man.curr[1]].occupant #they move out of there
if other.occupant is not None:
passengers[other.occupant].curr = cp
grid[man.curr[0]][man.curr[1]].occupant = i grid[man.curr[0]][man.curr[1]].occupant = i
time.sleep(0.1)
os.system("clear")
if done: if done:
exit() exit()

Loading…
Cancel
Save