コード例 #1
0
ファイル: tests.py プロジェクト: mylescpetersen/Battlesnake
    def test_avoid_neck_down(self):
        # Arrange
        test_head = {"x": 5, "y": 5}
        test_body = [{"x": 5, "y": 5}, {"x": 5, "y": 4}, {"x": 5, "y": 3}]
        possible_moves = ["up", "down", "left", "right"]
        expected = ["up", "left", "right"]

        # Act
        result_moves = avoid_my_neck(test_head, test_body, possible_moves)

        # Assert
        self.assertEqual(len(result_moves), 3)
        self.assertEqual(expected, result_moves)
コード例 #2
0
ファイル: tests.py プロジェクト: mylescpetersen/Battlesnake
    def test_avoid_neck_all(self):
        """
        The possible move set should be all moves.

        In the starter position, a Battlesnake body is 'stacked' in a
        single place, and thus all directions are valid.
        """
        # Arrange
        test_head = {"x": 5, "y": 5}
        test_body = [{"x": 5, "y": 5}, {"x": 5, "y": 5}, {"x": 5, "y": 5}]
        possible_moves = ["up", "down", "left", "right"]

        # Act
        result_moves = avoid_my_neck(test_head, test_body, possible_moves)

        # Assert
        self.assertEqual(len(result_moves), 4)
        self.assertEqual(possible_moves, result_moves)