w = 1
h = 1
- def __init__(self):
+ def __init__(self, i, j):
+ self.x = i
+ self.y = j
self.emissions = []
def add_emission(self, emission):
for i in range(nb_lines):
grid.append([])
for j in range(7):
- grid[-1].append(TimeCell())
+ grid[-1].append(TimeCell(i, j))
nonstop = [x for x in nonstops if i>=x[0]*2 and i<x[1]*2][0]
for time_cell in grid[-1]:
t += 1
except IndexError:
pass
+ grid[i] = [x for x in grid[i] if x is not None]
for i in range(nb_lines):
grid[i] = [x for x in grid[i] if x is not None]
continue
t = 1
try:
- while grid[i+t][j] == cell and grid[i+t][j].w == cell.w:
+ while True:
+ same_cell_below = [(bj, x) for bj, x in enumerate(grid[i+cell.h])
+ if x == cell and x.y == cell.y and x.w == cell.w]
+ if not same_cell_below:
+ break
+ bj, same_cell_below = same_cell_below[0]
+ del grid[i+cell.h][bj]
cell.h += 1
- grid[i+t][j] = None
- t += 1
except IndexError:
pass