|
@ -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,18 @@ grid=makeGrid() |
|
|
#boarding order |
|
|
#boarding order |
|
|
passengers = GenPassList(grid) |
|
|
passengers = GenPassList(grid) |
|
|
|
|
|
|
|
|
|
|
|
import random |
|
|
|
|
|
random.seed(505) |
|
|
|
|
|
random.shuffle(passengers) |
|
|
toad = 0 |
|
|
toad = 0 |
|
|
btime = 10 #passengers board every btime ticks |
|
|
btime = 10 #passengers board every btime ticks |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
def nunty(x): |
|
|
|
|
|
if x is None: return -1 |
|
|
|
|
|
return x |
|
|
def tick(t): |
|
|
def tick(t): |
|
|
done=True |
|
|
done=True |
|
|
global toad |
|
|
global toad |
|
@ -83,14 +93,15 @@ def tick(t): |
|
|
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) and t % btime == 0: |
|
|
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 and t % btime == 0: |
|
|
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 |
|
@ -99,14 +110,20 @@ def tick(t): |
|
|
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 |
|
|
if done and toad >= len(passengers): |
|
|
time.sleep(0.1) |
|
|
print("Final Tick: " + str(t)); |
|
|
os.system("clear") |
|
|
|
|
|
if done: |
|
|
exit() |
|
|
exit() |
|
|
|
|
|
|
|
|
def run(): |
|
|
def run(): |
|
|