Open chengjun opened 4 years ago
def AdjustNeighborCounts(row, race_of_mover, delta):
# row = 3
# race_of_mover = "darkred"
# delta = 1
curr_x = int(row) % side
curr_y = np.floor(int(row)/side)
condition1 = df['x'].isin(range(int(curr_x) - depth, int(curr_x) + depth+1))
condition2 = df['y'].isin(range(int(curr_y) - depth, int(curr_y) + depth+1))
condition3 = ~ ((df['x']==curr_x) & (df['y']==curr_y))
row_index = df[(condition1) & (condition2) & (condition3)].index
col_index = [race_of_mover, "num.neighbors"]
df.loc[row_index, col_index]+=delta