def test_block_fork(player_mark): other_mark = other_player(player_mark) ai = AI(player_mark) board = Board() board._rows = [[other_mark, ' ', ' '], [' ', player_mark, ' '], [' ', ' ', other_mark]] assert ai.turn(board.representation()) in ((0, 2), (2, 0)) board._rows = [[player_mark, ' ', ' '], [' ', other_mark, ' '], [' ', ' ', other_mark]] assert ai.turn(board.representation()) in ((0, 2), (2, 0))
def test_win(player_mark): ai = AI(player_mark) board = Board() board._rows = [[player_mark, ' ', player_mark], [' ', ' ', ' '], [' ', ' ', ' ']] assert ai.turn(board.representation()) == (0, 1) board._rows = [[' ', player_mark, ' '], [' ', player_mark, ' '], [' ', ' ', ' ']] assert ai.turn(board.representation()) == (2, 1) board._rows = [[' ', ' ', ' '], [' ', player_mark, ' '], [' ', ' ', player_mark]] assert ai.turn(board.representation()) == (0, 0) board._rows = [[' ', ' ', player_mark], [' ', ' ', ' '], [player_mark, ' ', ' ']] assert ai.turn(board.representation()) == (1, 1)
def test_create_fork(player_mark): other_mark = other_player(player_mark) ai = AI(player_mark) board = Board() board._rows = [[player_mark, ' ', ' '], [' ', other_mark, ' '], [' ', ' ', player_mark]] assert ai.turn(board.representation()) in ((2, 0), (0, 2)) board._rows = [[player_mark, ' ', ' '], [player_mark, ' ', ' '], [' ', ' ', ' ']] assert ai._fork(board.representation()) == (1, 1)
def test_block(player_mark): other_mark = other_player(player_mark) ai = AI(player_mark) board = Board() board._rows = [[other_mark, ' ', other_mark], [' ', ' ', ' '], [' ', ' ', ' ']] assert ai.turn(board.representation()) == (0, 1) board._rows = [[' ', other_mark, ' '], [' ', other_mark, ' '], [' ', ' ', ' ']] assert ai.turn(board.representation()) == (2, 1) board._rows = [[' ', ' ', ' '], [' ', other_mark, ' '], [' ', ' ', other_mark]] assert ai.turn(board.representation()) == (0, 0) board._rows = [[' ', ' ', other_mark], [' ', ' ', ' '], [other_mark, ' ', ' ']] assert ai.turn(board.representation()) == (1, 1) board._rows = [[player_mark, ' ', ' '], [other_mark, other_mark, ' '], [player_mark, ' ', other_mark]] assert ai.turn(board.representation()) == (1, 2)