if is_valid_coordinates(row + r, col + c): candidates.append((row + r, col + c)) return candidates def update_possible_coordinates(board, name, row, col, code): print("{0} can go to those coordinates from {1}, {2}: ".format( name, row, col)) for r, c in next_possible_coordinates(row, col, code): board[r][c] = 100 if __name__ == '__main__': from helper import create_empty_board cha_code = name2code('Cha-a') board = create_empty_board() board[1][1] = cha_code print("Cha can go to those coordinates from 1, 1: ") for r, c in next_possible_coordinates(1, 1, cha_code): board[r][c] = 100 print(board_state(board)) po_code = name2code('Po-a') board = create_empty_board() board[2][2] = po_code print("Po can go to those coordinates from 2, 2: ") for r, c in next_possible_coordinates(2, 2, po_code): board[r][c] = 100 print(board_state(board)) byung_code = name2code('Byung-a')
def reset(self): self.board = create_empty_board() for row, col, code in A_INITIAL_STATE+B_INITIAL_STATE: self.board[row][col] = code
def item_next_possible_coordinates(name, row, col): candidates = [] for r, c in MOVES[name.split('-')[0]]: if is_valid_coordinates(row + r, col + c): candidates.append((row + r, col + c)) return candidates def update_possible_coordinates(board, name, row, col, code): print("{0} can go to those coordinates from {1}, {2}: ".format(name, row, col)) for r, c in next_possible_coordinates(row, col, code): board[r][c] = 100 if __name__ == '__main__': from helper import create_empty_board cha_code = name2code('Cha-a') board = create_empty_board() board[1][1] = cha_code print("Cha can go to those coordinates from 1, 1: ") for r, c in next_possible_coordinates(1, 1, cha_code): board[r][c] = 100 print(board_state(board)) po_code = name2code('Po-a') board = create_empty_board() board[2][2] = po_code print("Po can go to those coordinates from 2, 2: ") for r, c in next_possible_coordinates(2, 2, po_code): board[r][c] = 100 print(board_state(board)) byung_code = name2code('Byung-a')
def reset(self): self.board = create_empty_board() for row, col, code in A_INITIAL_STATE + B_INITIAL_STATE: self.board[row][col] = code