def pre_calc_distance(gamestate):
    gamestate.distance_table = {}
    for row in range(gamestate.rows):
        for col in range(gamestate.cols):
            gamestate.distance_table[(row,col)] = np.zeros((gamestate.rows, gamestate.cols), dtype=int) + 100
            for d_row in range(row-5, row+6):
                for d_col in range(col-5, col+6):
                    d_row = d_row % gamestate.rows
                    d_col = d_col % gamestate.cols
                    gamestate.distance_table[(row,col)][d_row, d_col] = \
                        cython_ext2.euclidean_distance2(row, col, d_row, d_col, gamestate.rows, gamestate.cols)
def pre_calc_distance(gamestate):
    gamestate.distance_table = {}
    for row in range(gamestate.rows):
        for col in range(gamestate.cols):
            gamestate.distance_table[(row, col)] = np.zeros(
                (gamestate.rows, gamestate.cols), dtype=int) + 100
            for d_row in range(row - 5, row + 6):
                for d_col in range(col - 5, col + 6):
                    d_row = d_row % gamestate.rows
                    d_col = d_col % gamestate.cols
                    gamestate.distance_table[(row,col)][d_row, d_col] = \
                        cython_ext2.euclidean_distance2(row, col, d_row, d_col, gamestate.rows, gamestate.cols)
Esempio n. 3
0
 def euclidean_distance2(self, loc1, loc2):
     row1, col1 = loc1
     row2, col2 = loc2
     return cython_ext2.euclidean_distance2(row1, col1, row2, col2, self.rows, self.cols)
Esempio n. 4
0
 def euclidean_distance2(self, loc1, loc2):
     row1, col1 = loc1
     row2, col2 = loc2
     return cython_ext2.euclidean_distance2(row1, col1, row2, col2,
                                            self.rows, self.cols)