def test_is_this_move_a_victory(self):
     board = Board()
     checker = LogicChecker(board)
     assert checker.is_this_move_a_victory('X', 2, 3) == False
 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
示例#3
0
current_player = 'X'
while 1:
    print("------------------------------------------------")
    print("\t\tRound ", math.ceil(logic.turn / 2), ":\n\n\tPlayer ",
          current_player, " - it is your turn.\n")

    board.draw()

    player_choice = in_handler.get_player_choice(current_player)

    if player_choice == 'surrender':
        break
    else:
        board.insert(current_player, *player_choice)

    if logic.is_this_move_a_victory(current_player, *player_choice):
        board.draw()
        print("\n-------------------------------------------------")
        print("\nPlayer", current_player, "has won after",
              math.ceil(logic.turn / 2), "rounds!!\nAll hail the victor!\n")
        print("-------------------------------------------------\n\n")
        break

    if logic.turn >= 7:
        if logic.would_this_be_a_draw(current_player,
                                      board.empty_tile_coordinates()):
            board.draw()
            print("\n-------------------------------------------------")
            print("\nA draw after", math.ceil(logic.turn / 2),
                  "rounds!!\nGood work both!\n")
            print("-------------------------------------------------\n\n\n")