Clean up ANDs

This commit is contained in:
Luke Hubmayer-Werner 2020-12-11 17:46:04 +10:30
parent 11208c7e33
commit d7fbb4d559
1 changed files with 4 additions and 4 deletions

View File

@ -10,8 +10,8 @@ def sim_step(seatmap, seatfilled):
src = dir_slices[(i+4)%8] src = dir_slices[(i+4)%8]
neighbours[dst] += seatfilled[src] neighbours[dst] += seatfilled[src]
output = seatfilled.copy() output = seatfilled.copy()
output[np.logical_and(seatfilled==True, neighbours>=4)] = False output[(seatfilled==True) & (neighbours>=4)] = False
output[np.logical_and(seatfilled==False, np.logical_and(neighbours==0, seatmap==True))] = True output[(seatfilled==False) & (neighbours==0) & (seatmap==True)] = True
return output return output
occupied_seats = seatmap & False occupied_seats = seatmap & False
@ -36,8 +36,8 @@ def sim_step_los(seatmap, seatfilled):
break break
neighbours[dst] += fill2[src] neighbours[dst] += fill2[src]
output = seatfilled.copy() output = seatfilled.copy()
output[np.logical_and(seatfilled==True, neighbours>=5)] = False output[(seatfilled==True) & (neighbours>=5)] = False
output[np.logical_and(seatfilled==False, np.logical_and(neighbours==0, seatmap==True))] = True output[(seatfilled==False) & (neighbours==0) & (seatmap==True)] = True
return output return output
occupied_seats = seatmap & False occupied_seats = seatmap & False