Esempio n. 1
0
 def test_check_diagonal_first_row(self):
     board = Board()
     board.insert('X', 4, 4)
     board.insert('X', 2, 2)
     checker = LogicChecker(board)
     
     assert checker._check_diagonal('X', 0, 0) == True
Esempio n. 2
0
    def test_check_vertical_first_column_false(self):
        board = Board()
        board.insert('X', 0, 0)
        board.insert('X', 0, 2)
        checker = LogicChecker(board)

        assert checker._check_vertical('X', 2, 4) == False
Esempio n. 3
0
 def test_check_diagonal_other_symbol(self):
     board = Board()
     board.insert('O', 0, 0)
     board.insert('O', 4, 4)
     checker = LogicChecker(board)
     
     assert checker._check_diagonal('O', 2, 2) == True
Esempio n. 4
0
 def test_check_diagonal_symbol_mismatch(self):
     board = Board()
     board.insert('O', 0, 0)
     board.insert('X', 4, 4)
     checker = LogicChecker(board)
     
     assert checker._check_diagonal('O', 2, 2) == False
Esempio n. 5
0
    def test_check_vertical_second_column(self):
        board = Board()
        board.insert('X', 2, 0)
        board.insert('X', 2, 2)
        checker = LogicChecker(board)

        assert checker._check_vertical('X', 2, 4) == True
Esempio n. 6
0
 def test_check_diagonal_last_row_false(self):
     board = Board()
     board.insert('X', 0, 2)
     board.insert('X', 2, 2)
     checker = LogicChecker(board)
     
     assert checker._check_diagonal('X', 4, 4) == False
Esempio n. 7
0
    def test_check_diagonal_topright_to_bottom_left(self):
        board = Board()
        board.insert('X', 4, 0)
        board.insert('X', 2, 2)
        checker = LogicChecker(board)

        board.draw()
        
        assert checker._check_diagonal('X', 0, 4) == True
Esempio n. 8
0
    def test_check_diagonal_middle_row_false(self):
        board = Board()
        board.insert('X', 0, 0)
        board.insert('X', 4, 0)
        checker = LogicChecker(board)

        board.draw()
        
        assert checker._check_diagonal('X', 2, 2) == False
Esempio n. 9
0
 def test_diagonal_victory_in_1(self):
     board = Board()
     checker = LogicChecker(board)
     checker.turn = 9
     board.game_board = [[' ', '|', 'X', '|', 'O'],
                         ['--', '+', '--', '+', '--'],
                         ['O', '|', 'X', '|', 'X'],
                         ['--', '+', '--', '+', '--'],
                         ['O', '|', 'O', '|', 'X']]
     assert checker.would_this_be_a_draw('X', [(0,0)]) == False
Esempio n. 10
0
 def test_one_remaining_2(self):
     board = Board()
     checker = LogicChecker(board)
     checker.turn = 9
     board.game_board = [['X', '|', 'X', '|', 'O'],
                         ['--', '+', '--', '+', '--'],
                         ['O', '|', ' ', '|', 'X'],
                         ['--', '+', '--', '+', '--'],
                         ['X', '|', 'O', '|', 'O']]
     assert checker.would_this_be_a_draw('X', [(2,2)]) == True
Esempio n. 11
0
 def test_two_remaining(self):
     board = Board()
     checker = LogicChecker(board)
     checker.turn = 8
     board.game_board = [['X', '|', 'O', '|', 'X'],
                         ['--', '+', '--', '+', '--'],
                         ['X', '|', 'O', '|', ' '],
                         ['--', '+', '--', '+', '--'],
                         ['O', '|', 'X', '|', ' ']]
     assert checker.would_this_be_a_draw('O', [(4,2), (4,4)]) == True
Esempio n. 12
0
 def test_empty_board(self):
     board = Board()
     checker = LogicChecker(board)
     board.game_board = [[' ', '|', ' ', '|', ' '],
                         ['--', '+', '--', '+', '--'],
                         [' ', '|', ' ', '|', ' '],
                         ['--', '+', '--', '+', '--'],
                         [' ', '|', ' ', '|', ' ']]
     assert checker.would_this_be_a_draw('X', [(0,0),(2,0),(4,0),
                                               (0,2),(2,2),(4,2),
                                               (0,4),(2,4),(4,4)]) == False
Esempio n. 13
0
    def test_mistake_possible_2(self):
        board = Board()
        checker = LogicChecker(board)
        checker.turn = 8

        board.game_board = [['X', '|', ' ', '|', 'X'],
                            ['--', '+', '--', '+', '--'],
                            ['X', '|', 'X', '|', 'O'],
                            ['--', '+', '--', '+', '--'],
                            ['O', '|', 'O', '|', ' ']]

        checker.board.draw()

        assert checker.would_this_be_a_draw('O', [(2,0), (4,4)]) == False
Esempio n. 14
0
import math

from src.classes.Board import Board
from src.classes.LogicChecker import LogicChecker
from src.classes.InputHandler import InputHandler

board = Board()  #This is the game board itself
logic = LogicChecker(board)

help_board = Board(
)  #This is a board that helps the user pick where to place their X or O.

help_board.insert('1', 0, 0)
help_board.insert('2', 2, 0)
help_board.insert('3', 4, 0)

help_board.insert('4', 0, 2)
help_board.insert('5', 2, 2)
help_board.insert('6', 4, 2)

help_board.insert('7', 0, 4)
help_board.insert('8', 2, 4)
help_board.insert('9', 4, 4)

in_handler = InputHandler(help_board, board)
"""Main Loop"""

current_player = 'X'
while 1:
    print("------------------------------------------------")
    print("\t\tRound ", math.ceil(logic.turn / 2), ":\n\n\tPlayer ",
Esempio n. 15
0
 def test_is_this_move_a_victory(self):
     board = Board()
     checker = LogicChecker(board)
     assert checker.is_this_move_a_victory('X', 2, 3) == False
Esempio n. 16
0
 def test_is_this_move_a_victory_true(self):
     board = Board()
     board.insert('X', 0, 0)
     board.insert('X', 2, 2)
     checker = LogicChecker(board)
     assert checker.is_this_move_a_victory('X', 4, 4) == True
Esempio n. 17
0
 def test_check_horizontal_second_row_false(self):
     board = Board()
     board.insert('X', 0, 2)
     board.insert('X', 2, 2)
     checker = LogicChecker(board)
     assert checker._check_horizontal('X', 2, 4) == False
Esempio n. 18
0
 def test_check_horizontal_first_row(self):
     board = Board()
     board.insert('X', 0, 0)
     board.insert('X', 2, 0)
     checker = LogicChecker(board)
     assert checker._check_horizontal('X', 4, 0) == True