예제 #1
0
파일: rule.py 프로젝트: vipmath/janggi-1
        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')
예제 #2
0
 def reset(self):
     self.board = create_empty_board()
     for row, col, code in A_INITIAL_STATE+B_INITIAL_STATE:
         self.board[row][col] = code
예제 #3
0
파일: rule.py 프로젝트: ParkOhyoung/janggi
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')
예제 #4
0
 def reset(self):
     self.board = create_empty_board()
     for row, col, code in A_INITIAL_STATE + B_INITIAL_STATE:
         self.board[row][col] = code