Ejemplo n.º 1
0
def create_moves(rows, columns, row, column):
    """
    Test creating all knight moves
    
    >>> create_moves(rows = 8, columns = 8, row = 8, column = 8)
    ((1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1))
    """
    board = Board(rows, columns)
    position = Position(row, column, board)
    knight = Knight(position)
    return knight.create_moves()
def create_moves(rows, columns, row, column):
    """
    Test creating all knight moves
    
    >>> create_moves(rows = 8, columns = 8, row = 8, column = 8)
    ((1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1))
    """
    board = Board(rows, columns)
    position = Position(row, column, board)
    knight = Knight(position)
    return knight.create_moves()
Ejemplo n.º 3
0
def retrace_pop(rows, columns, row1, column1, row2, column2):
    """
    >>> retrace_pop(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    (4, 5)

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    knight.record_visited_position(position2)
    return knight.retrace().coordinate
Ejemplo n.º 4
0
def valid_possible_position2(rows, columns, row1, column1, row2, column2):
    """
    >>> valid_possible_position2(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    False

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    knight.record_visited_position(position2)
    return knight._valid_position(position2)
def retrace_pop(rows, columns, row1, column1, row2, column2):
    """
    >>> retrace_pop(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    (4, 5)

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    knight.record_visited_position(position2)
    return knight.retrace().coordinate
def valid_possible_position2(rows, columns, row1, column1, row2, column2):
    """
    >>> valid_possible_position2(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    False

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    knight.record_visited_position(position2)
    return knight._valid_position(position2)
Ejemplo n.º 7
0
def knight_moves(rows, columns, row1, column1, row2, column2):
    """
    Tests to see if a second knight is created, it has the proper knight moves
    >>> knight_moves(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    True

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight1 = Knight(position1)
    knight2 = Knight(position2)
    return knight1.moves == knight2.moves
Ejemplo n.º 8
0
def get_possible_moves(rows, columns, row, column):
    """
    >>> get_possible_moves(rows = 8, columns = 8, row = 8, column = 8)
    [(7, 6), (6, 7)]
    >>> get_possible_moves(rows = 8, columns = 8, row = 4, column = 5)
    [(5, 7), (5, 3), (3, 7), (3, 3), (6, 6), (6, 4), (2, 6), (2, 4)]
    """
    board = Board(rows, columns)
    position = Position(row, column, board)
    knight = Knight(position)
    positions = []
    for p in knight.get_possible_moves():
        positions.append(p.coordinate)
    return positions
Ejemplo n.º 9
0
def valid_possible_position3(rows, columns, row1, column1, row2, column2):
    """
    >>> valid_possible_position3(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    True
    >>> valid_possible_position3(rows=8, columns=8, row1=4, column1=5, row2=5, column2=11)
    False
    >>> valid_possible_position3(rows=8, columns=8, row1=9, column1=9, row2=5, column2=7)
    True
    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    return knight._valid_position(position2)
def get_possible_moves(rows, columns, row, column):
    """
    >>> get_possible_moves(rows = 8, columns = 8, row = 8, column = 8)
    [(7, 6), (6, 7)]
    >>> get_possible_moves(rows = 8, columns = 8, row = 4, column = 5)
    [(5, 7), (5, 3), (3, 7), (3, 3), (6, 6), (6, 4), (2, 6), (2, 4)]
    """
    board = Board(rows, columns)
    position = Position(row, column, board)
    knight = Knight(position)
    positions = []
    for p in knight.get_possible_moves():
        positions.append(p.coordinate)
    return positions
def valid_possible_position3(rows, columns, row1, column1, row2, column2):
    """
    >>> valid_possible_position3(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    True
    >>> valid_possible_position3(rows=8, columns=8, row1=4, column1=5, row2=5, column2=11)
    False
    >>> valid_possible_position3(rows=8, columns=8, row1=9, column1=9, row2=5, column2=7)
    True
    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    return knight._valid_position(position2)
Ejemplo n.º 12
0
def record_visited_position(rows, columns, row1, column1, row2, column2):
    """
    >>> record_visited_position(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    [(4, 5), (5, 7)]

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    knight.record_visited_position(position2)
    positions = []
    for pos in knight.visited_positions:
        positions.append(pos.coordinate)
    return positions
def record_visited_position(rows, columns, row1, column1, row2, column2):
    """
    >>> record_visited_position(rows=8, columns=8, row1=4, column1=5, row2=5, column2=7)
    [(4, 5), (5, 7)]

    """
    board = Board(rows, columns)
    position1 = Position(row1, column1, board)
    position2 = Position(row2, column2, board)
    knight = Knight(position1)
    knight.record_visited_position(position2)
    positions = []
    for pos in knight.visited_positions:
        positions.append(pos.coordinate)
    return positions