コード例 #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
ファイル: janggi.py プロジェクト: ParkOhyoung/janggi
 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