def testIsHorizontalWin4(self):  # Only 1 piece on board. not any win.
     """
     GIVEN: a game_state without any win, and the coordinates of the last placed piece
     WHEN: is_horizontal_win((x, y)) is called
     THEN: False is returned
     """
     connect_four.game_state = [[None, None, False, None, None, None, None],
                                [None, None, None, None, None, None, None],
                                [None, None, None, None, None, None, None],
                                [None, None, None, None, None, None, None],
                                [None, None, None, None, None, None, None],
                                [None, None, None, None, None, None, None]]
     isWin = connect_four.is_horizontal_win((-30, -150))
     self.assertEqual(isWin, False)
 def testIsHorizontalWin2(self):  # horizontal win RED
     """
     GIVEN: a game_state with a horizontal win, and the coordinates of the last placed piece
     WHEN: is_horizontal_win((x, y)) is called
     THEN: True is returned
     """
     connect_four.game_state = [[
         None, None, False, False, True, False, None
     ], [None, None, True, True, False, True,
         None], [None, None, False, False, False, False, None],
                                [None, None, True, True, True, None, None],
                                [None, None, None, None, None, None, None],
                                [None, None, None, None, None, None, None]]
     isWin = connect_four.is_horizontal_win((120, -50))
     self.assertEqual(isWin, True)
 def testIsHorizontalWin5(self):  # Not a horizontal win
     """
     GIVEN: a game_state without a horizontal win, and the coordinates of the last placed piece
     WHEN: is_horizontal_win((x, y)) is called
     THEN: False is returned
     """
     connect_four.game_state = [
         [False, True, True, True, None, None, None],
         [None, False, False, True, None, None, None],
         [None, True, False, False, None, None, None],
         [None, None, None, False, None, None, None],
         [None, None, None, None, None, None, None],
         [None, None, None, None, None, None, None]
     ]
     isHorWin = connect_four.is_horizontal_win((20, 0))
     self.assertEqual(isHorWin, False)
 def testIsHorizontalWin3(self):  # full board horizontal win
     """
     GIVEN: a game_state with a horizontal win, and the coordinates of the last placed piece
     WHEN: is_horizontal_win((x, y)) is called
     THEN: True is returned (even if the board is full)
     """
     connect_four.game_state = [
         [False, True, False, False, False, True, False],
         [False, False, True, True, True, False, True],
         [True, True, False, False, False, True, False],
         [False, False, True, True, True, False, True],
         [True, True, False, False, False, True, False],
         [False, True, True, True, True, False, True]
     ]
     isWin = connect_four.is_horizontal_win((-80, 100))
     self.assertEqual(isWin, True)
コード例 #5
0
def test_is_horizontal_win():
    assert is_horizontal_win((1, 0)) is True