def test_some_chains(self):
        """
        should return all the chains in a list ignoring squares which arent in a chain or that have been taken
        """
        unplay_all(board)

        # Chains 0, 1 10 19 20, 23 30
        edges = (0,17,9,10,26,27,42,48,36,49,45,46,55,56,66,7,15,16,24)
        edge_setter(edges, const.PLAYED, board)

        result = finder.find_all(board)

        print(result)

        self.assertEqual(len(result), 5)

        one_chains = []
        for chain in result:
            if len(chain) == 1:
                one_chains.append(chain)
            elif len(chain) == 4:
                self.assertIn(1, chain)
                self.assertIn(10, chain)
                self.assertIn(19, chain)
                self.assertIn(20, chain)
            elif len(chain) == 2:
                self.assertIn(23, chain)
                self.assertIn(30, chain)
            else:
                self.assertFail("Chains were not the right length")

        self.assertEqual(len(one_chains), 3)
        self.assertIn([0], one_chains)
        self.assertIn([9], one_chains)
        self.assertIn([11], one_chains)
    def test_complex_chain_end(self):
        """
        should return all the squares in the chain, including the one given
        """
        unplay_all(board)

        # Set some random edges to played
        random_edges = (14, 33, 59, 60, 70, 71)
        edge_setter(random_edges, const.PLAYED, board)

        # Test a very complex chain, traversing squares 19, 20, 11, 12, 13, 14, 23, 24, 15
        square_ids = (19, 20, 11, 12, 13, 14, 23, 24, 15)
        chain_edges = (35, 48, 49, 44, 27, 19, 37, 20, 21, 38, 22, 31, 45, 50,
                       51, 47, 31, 23)
        edge_setter(chain_edges, const.PLAYED, board)

        traversal = finder.traverse(15, board)
        self.assertEqual(len(traversal), len(square_ids))
        for square in square_ids:
            self.assertIn(square, traversal)

        edge_setter(chain_edges, const.UNPLAYED, board)

        # Unset the random edges
        edge_setter(random_edges, const.UNPLAYED, board)
Example #3
0
 def test_with_one(self):
     """
     should return 1 when the given square has 1 played edges
     """
     unplay_all(board)
     board.setEdgeState(13, const.PLAYED)
     self.assertEqual(placer._get_square_no_of_played(5, board), 1)
    def test_edge(self):
        """
        should return None if there is no square on the other side
        """
        unplay_all(board)

        self.assertEqual(finder._square_over_edge(8, 0, board), None)
 def test_with_one(self):
     """
     should return 1 when the given square has 1 played edges
     """
     unplay_all(board)
     board.setEdgeState(13, const.PLAYED)
     self.assertEqual(placer._get_square_no_of_played(5, board), 1)
    def test_down(self):
        """
        should return the square on the other side of the edge traversing down
        """
        unplay_all(board)

        self.assertEqual(finder._square_over_edge(20, 3, board), 12)
    def test_down(self):
        """
        should return the square on the other side of the edge traversing down
        """
        unplay_all(board)

        self.assertEqual(finder._square_over_edge(20, 3, board), 12)
    def test_left(self):
        """
        should return the square on the other side of the edge traversing left
        """
        unplay_all(board)

        self.assertEqual(finder._square_over_edge(9, 1, board), 0)
    def test_edge(self):
        """
        should return None if there is no square on the other side
        """
        unplay_all(board)

        self.assertEqual(finder._square_over_edge(8, 0, board), None)
    def test_left(self):
        """
        should return the square on the other side of the edge traversing left
        """
        unplay_all(board)

        self.assertEqual(finder._square_over_edge(9, 1, board), 0)
 def test_one_edge_count(self):
     """
     should return the traversable square in a list
     """
     unplay_all(board)
     
     edges = (27,28,43,44)
     edge_setter(edges, const.PLAYED, board)
     result = finder._get_traversable_squares(11, board)
     self.assertEqual([20], result)
 def test_one_edge_of_board(self):
     """
     should return the traversable square in a list
     """
     unplay_all(board)
     
     edges = (0,17,1,10)
     edge_setter(edges, const.PLAYED, board)
     result = finder._get_traversable_squares(0, board)
     self.assertEqual([1], result)
    def test_none(self):
        """
        should return the reachable squares of a square
        """
        unplay_all(board)

        # Square zero, edge 8 unplayed
        edges = (0,9,17)
        edge_setter(edges, const.PLAYED, board)
        self.assertEqual(finder._get_traversable_squares(0, board), [])
    def test_no_chain(self):
        """
        should return all the squares passed
        """
        unplay_all(board)

        squares = (5, 14, 15)
        result = finder._filter_in_chain(squares, [])
        for square in squares:
            self.assertIn(square, result)
    def test_no_chains(self):
        """
        should return empty list if there are no chains
        """
        unplay_all(board)

        edges = (0,3,4,7,33,45,49,58,62,63,68)
        edge_setter(edges, const.PLAYED, board)

        self.assertEqual(finder.find_all(board), [])
 def test_single(self):
     """
     should return a list of one square when the chain is one long
     """
     unplay_all(board)
     board.setEdgeState(66, const.PLAYED)
     board.setEdgeState(71, const.PLAYED)
     self.assertEqual([37], finder.traverse(37, board))
     board.setEdgeState(66, const.UNPLAYED)
     board.setEdgeState(71, const.UNPLAYED)
    def test_one(self):
        """
        should return the free square in an array (for consistancey)
        """
        unplay_all(board)

        edges = (0,1,19,12,31,40,71,66,61,67,56,57)
        edge_setter(edges, const.PLAYED, board)

        self.assertEqual(placer.get_free_squares(board), [31])
    def test_no_chain(self):
        """
        should return all the squares passed
        """
        unplay_all(board)

        squares = (5,14,15)
        result = finder._filter_in_chain(squares, [])
        for square in squares:
            self.assertIn(square, result)
    def test_one_edge_of_board(self):
        """
        should return the traversable square in a list
        """
        unplay_all(board)

        edges = (0, 17, 1, 10)
        edge_setter(edges, const.PLAYED, board)
        result = finder._get_traversable_squares(0, board)
        self.assertEqual([1], result)
    def test_none(self):
        """
        should return [] when there are no free sqaures
        """
        unplay_all(board)

        edges = (0,1,19,12,31,40,71,66,61,67)
        edge_setter(edges, const.PLAYED, board)

        self.assertEqual(placer.get_free_squares(board), [])
    def test_none(self):
        """
        should return the reachable squares of a square
        """
        unplay_all(board)

        # Square zero, edge 8 unplayed
        edges = (0, 9, 17)
        edge_setter(edges, const.PLAYED, board)
        self.assertEqual(finder._get_traversable_squares(0, board), [])
    def test_no_chains(self):
        """
        should return empty list if there are no chains
        """
        unplay_all(board)

        edges = (0, 3, 4, 7, 33, 45, 49, 58, 62, 63, 68)
        edge_setter(edges, const.PLAYED, board)

        self.assertEqual(finder.find_all(board), [])
    def test_one_edge_count(self):
        """
        should return the traversable square in a list
        """
        unplay_all(board)

        edges = (27, 28, 43, 44)
        edge_setter(edges, const.PLAYED, board)
        result = finder._get_traversable_squares(11, board)
        self.assertEqual([20], result)
 def test_single(self):
     """
     should return a list of one square when the chain is one long
     """
     unplay_all(board)
     board.setEdgeState(66, const.PLAYED)
     board.setEdgeState(71, const.PLAYED)
     self.assertEqual([37], finder.traverse(37, board))
     board.setEdgeState(66, const.UNPLAYED)
     board.setEdgeState(71, const.UNPLAYED)
Example #25
0
    def test_none(self):
        """
        should return [] when there are no free sqaures
        """
        unplay_all(board)

        edges = (0, 1, 19, 12, 31, 40, 71, 66, 61, 67)
        edge_setter(edges, const.PLAYED, board)

        self.assertEqual(placer.get_free_squares(board), [])
Example #26
0
    def test_one(self):
        """
        should return the free square in an array (for consistancey)
        """
        unplay_all(board)

        edges = (0, 1, 19, 12, 31, 40, 71, 66, 61, 67, 56, 57)
        edge_setter(edges, const.PLAYED, board)

        self.assertEqual(placer.get_free_squares(board), [31])
    def test_chain(self):
        """
        should return all those passed, except those in the chain
        """
        unplay_all(board)

        squares = (5, 14, 15, 20)
        chain = (12, 15, 6, 5)
        result = finder._filter_in_chain(squares, chain)
        self.assertIn(14, result)
        self.assertIn(20, result)
        self.assertNotIn(5, result)
        self.assertNotIn(15, result)
    def test_chain(self):
        """
        should return all those passed, except those in the chain
        """
        unplay_all(board)

        squares = (5,14,15,20)
        chain = (12, 15, 6, 5)
        result = finder._filter_in_chain(squares, chain)
        self.assertIn(14, result)
        self.assertIn(20, result)
        self.assertNotIn(5, result)
        self.assertNotIn(15, result)
    def test_when_unsafe(self):
        """
        should return unsafe when placing an edge would give the opponent a square
        """
        unplay_all(board)

        edge1 = 30
        edge2 = 22
        edge3 = 50
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        board.setEdgeState(edge3, const.PLAYED)
        self.assertEqual(placer.check_safe(39, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        board.setEdgeState(edge3, const.UNPLAYED)

        edge1 = 30
        edge2 = 22
        edge3 = 32
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        board.setEdgeState(edge3, const.PLAYED)
        self.assertEqual(placer.check_safe(31, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        board.setEdgeState(edge3, const.UNPLAYED)

        edge1 = 32
        edge2 = 24
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        self.assertEqual(placer.check_safe(33, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)


        edge1 = 30
        edge2 = 22
        edge3 = 32
        edge4 = 23
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        board.setEdgeState(edge3, const.PLAYED)
        board.setEdgeState(edge4, const.PLAYED)
        self.assertEqual(placer.check_safe(31, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        board.setEdgeState(edge3, const.UNPLAYED)
        board.setEdgeState(edge4, const.UNPLAYED)
Example #30
0
    def test_when_unsafe(self):
        """
        should return unsafe when placing an edge would give the opponent a square
        """
        unplay_all(board)

        edge1 = 30
        edge2 = 22
        edge3 = 50
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        board.setEdgeState(edge3, const.PLAYED)
        self.assertEqual(placer.check_safe(39, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        board.setEdgeState(edge3, const.UNPLAYED)

        edge1 = 30
        edge2 = 22
        edge3 = 32
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        board.setEdgeState(edge3, const.PLAYED)
        self.assertEqual(placer.check_safe(31, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        board.setEdgeState(edge3, const.UNPLAYED)

        edge1 = 32
        edge2 = 24
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        self.assertEqual(placer.check_safe(33, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)

        edge1 = 30
        edge2 = 22
        edge3 = 32
        edge4 = 23
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        board.setEdgeState(edge3, const.PLAYED)
        board.setEdgeState(edge4, const.PLAYED)
        self.assertEqual(placer.check_safe(31, board), False)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        board.setEdgeState(edge3, const.UNPLAYED)
        board.setEdgeState(edge4, const.UNPLAYED)
    def test_X_junction(self):
        """
        should stop at a X junction
        """
        unplay_all(board)

        edges = (21, 38, 22, 39, 14, 15, 24, 41, 46, 47)
        squares = (13, 14)
        edge_setter(edges, const.PLAYED, board)
        traversal = finder.traverse(13, board)
        self.assertEqual(len(traversal), len(squares))
        for square in squares:
            self.assertIn(square, traversal)

        edge_setter(edges, const.UNPLAYED, board)
    def test_loop_chain_square(self):
        """
        should be able to return squares from a loop of a square chain
        """
        unplay_all(board)

        edges = (3, 4, 13, 30, 38, 37, 28, 11)
        squares = (3, 4, 12, 13)
        edge_setter(edges, const.PLAYED, board)
        traversal = finder.traverse(3, board)
        self.assertEqual(len(traversal), len(squares))
        for square in squares:
            self.assertIn(square, traversal)

        edge_setter(edges, const.UNPLAYED, board)
    def test_needs_better_name(self):
        """
        should return only squares which have 2 or more edges played
        """
        unplay_all(board)

        edges = (0, 1, 10, 2, 11)
        edge_setter(edges, const.PLAYED, board)

        squares = (0,1,2,3)
        filtered = finder._filter_edge_count(squares, board)
        self.assertNotIn(0, filtered)
        self.assertIn(1, filtered)
        self.assertIn(2, filtered)
        self.assertNotIn(3, filtered)
    def test_X_junction(self):
        """
        should stop at a X junction
        """
        unplay_all(board)

        edges = (21,38,22,39,14,15,24,41,46,47)
        squares = (13,14)
        edge_setter(edges, const.PLAYED, board)
        traversal = finder.traverse(13, board)
        self.assertEqual(len(traversal), len(squares))
        for square in squares:
            self.assertIn(square, traversal)

        edge_setter(edges, const.UNPLAYED, board)
    def test_needs_better_name(self):
        """
        should return only squares which have 2 or more edges played
        """
        unplay_all(board)

        edges = (0, 1, 10, 2, 11)
        edge_setter(edges, const.PLAYED, board)

        squares = (0, 1, 2, 3)
        filtered = finder._filter_edge_count(squares, board)
        self.assertNotIn(0, filtered)
        self.assertIn(1, filtered)
        self.assertIn(2, filtered)
        self.assertNotIn(3, filtered)
    def test_many(self):
        """
        should return all the free squares
        """
        unplay_all(board)

        edges = (0,1,19,12,31,40,71,66,61,67,56,57,62,58,63,52,53)
        edge_setter(edges, const.PLAYED, board)

        free_squares = placer.get_free_squares(board)

        self.assertIn(27, free_squares)
        self.assertIn(33, free_squares)
        self.assertIn(31, free_squares)
        self.assertNotIn(37, free_squares)
    def test_loop_chain_square(self):
        """
        should be able to return squares from a loop of a square chain
        """
        unplay_all(board)

        edges = (3, 4, 13, 30, 38, 37, 28, 11)
        squares = (3, 4, 12, 13)
        edge_setter(edges, const.PLAYED, board)
        traversal = finder.traverse(3, board)
        self.assertEqual(len(traversal), len(squares))
        for square in squares:
            self.assertIn(square, traversal)

        edge_setter(edges, const.UNPLAYED, board)
Example #38
0
    def test_many(self):
        """
        should return all the free squares
        """
        unplay_all(board)

        edges = (0, 1, 19, 12, 31, 40, 71, 66, 61, 67, 56, 57, 62, 58, 63, 52,
                 53)
        edge_setter(edges, const.PLAYED, board)

        free_squares = placer.get_free_squares(board)

        self.assertIn(27, free_squares)
        self.assertIn(33, free_squares)
        self.assertIn(31, free_squares)
        self.assertNotIn(37, free_squares)
    def test_loop_chain_rect(self):
        """
        should be able to return squares from a loop of a rectangular chain
        """
        unplay_all(board)

        # 3 x 2 rectangle, make sure edge count is always satisfied
        edges = (3, 4, 5, 14, 31, 39, 38, 37, 28, 11, 21)
        squares = (3, 4, 5, 14, 13, 12)
        edge_setter(edges, const.PLAYED, board)
        traversal = finder.traverse(3, board)
        self.assertEqual(len(traversal), len(squares))
        for square in squares:
            self.assertIn(square, traversal)

        edge_setter(edges, const.UNPLAYED, board)
    def test_loop_chain_rect(self):
        """
        should be able to return squares from a loop of a rectangular chain
        """
        unplay_all(board)

        # 3 x 2 rectangle, make sure edge count is always satisfied
        edges = (3, 4, 5, 14, 31, 39, 38, 37, 28, 11, 21)
        squares = (3, 4, 5, 14, 13, 12)
        edge_setter(edges, const.PLAYED, board)
        traversal = finder.traverse(3, board)
        self.assertEqual(len(traversal), len(squares))
        for square in squares:
            self.assertIn(square, traversal)

        edge_setter(edges, const.UNPLAYED, board)
    def test_complex_chain_end(self):
        """
        should return all the squares in the chain, including the one given
        """
        unplay_all(board)

        # Set some random edges to played
        random_edges = (14, 33, 59, 60, 70, 71)
        edge_setter(random_edges, const.PLAYED, board)

        # Test a very complex chain, traversing squares 19, 20, 11, 12, 13, 14, 23, 24, 15
        square_ids = (19, 20, 11, 12, 13, 14, 23, 24, 15)
        chain_edges = (35, 48, 49, 44, 27, 19, 37, 20, 21, 38, 22, 31, 45, 50, 51, 47, 31, 23)
        edge_setter(chain_edges, const.PLAYED, board)
        
        traversal = finder.traverse(15, board)
        self.assertEqual(len(traversal), len(square_ids))
        for square in square_ids:
            self.assertIn(square, traversal)

        edge_setter(chain_edges, const.UNPLAYED, board)

        # Unset the random edges
        edge_setter(random_edges, const.UNPLAYED, board)
    def test_some_chains(self):
        """
        should return all the chains in a list ignoring squares which arent in a chain or that have been taken
        """
        unplay_all(board)

        # Chains 0, 1 10 19 20, 23 30
        edges = (0, 17, 9, 10, 26, 27, 42, 48, 36, 49, 45, 46, 55, 56, 66, 7,
                 15, 16, 24)
        edge_setter(edges, const.PLAYED, board)

        result = finder.find_all(board)

        print(result)

        self.assertEqual(len(result), 5)

        one_chains = []
        for chain in result:
            if len(chain) == 1:
                one_chains.append(chain)
            elif len(chain) == 4:
                self.assertIn(1, chain)
                self.assertIn(10, chain)
                self.assertIn(19, chain)
                self.assertIn(20, chain)
            elif len(chain) == 2:
                self.assertIn(23, chain)
                self.assertIn(30, chain)
            else:
                self.assertFail("Chains were not the right length")

        self.assertEqual(len(one_chains), 3)
        self.assertIn([0], one_chains)
        self.assertIn([9], one_chains)
        self.assertIn([11], one_chains)
    def test_when_safe(self):
        """
        should return safe when placing an edge would not give the opponent a square
        """
        unplay_all(board)

        # 0 Left & Right
        self.assertEqual(placer.check_safe(9, board), True)

        # 0 Top & Bottom
        self.assertEqual(placer.check_safe(18, board), True)

        # 1 Left Parralel 
        edge = 9
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Left Top 
        edge = 1
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Left Bottom 
        edge = 1
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Right Parralel 
        edge = 11
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Right Top 
        edge = 2
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Right Bottom 
        edge = 19
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Top Left & 1 Bottom Parralel
        edge1 = 30
        edge2 = 50
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        self.assertEqual(placer.check_safe(39, board), True)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)

        # 1 Top Parralel & 1 Bottom Right
        edge1 = 22
        edge2 = 46
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        self.assertEqual(placer.check_safe(39, board), True)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)
        
        # Top no square bottom parralel 
        edge = 10
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(1, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # Left no square right top
        edge = 0
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(8, board), True)
        board.setEdgeState(edge, const.UNPLAYED)
Example #44
0
    def test_when_safe(self):
        """
        should return safe when placing an edge would not give the opponent a square
        """
        unplay_all(board)

        # 0 Left & Right
        self.assertEqual(placer.check_safe(9, board), True)

        # 0 Top & Bottom
        self.assertEqual(placer.check_safe(18, board), True)

        # 1 Left Parralel
        edge = 9
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Left Top
        edge = 1
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Left Bottom
        edge = 1
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Right Parralel
        edge = 11
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Right Top
        edge = 2
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Right Bottom
        edge = 19
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(10, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # 1 Top Left & 1 Bottom Parralel
        edge1 = 30
        edge2 = 50
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        self.assertEqual(placer.check_safe(39, board), True)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)

        # 1 Top Parralel & 1 Bottom Right
        edge1 = 22
        edge2 = 46
        board.setEdgeState(edge1, const.PLAYED)
        board.setEdgeState(edge2, const.PLAYED)
        self.assertEqual(placer.check_safe(39, board), True)
        board.setEdgeState(edge1, const.UNPLAYED)
        board.setEdgeState(edge2, const.UNPLAYED)

        # Top no square bottom parralel
        edge = 10
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(1, board), True)
        board.setEdgeState(edge, const.UNPLAYED)

        # Left no square right top
        edge = 0
        board.setEdgeState(edge, const.PLAYED)
        self.assertEqual(placer.check_safe(8, board), True)
        board.setEdgeState(edge, const.UNPLAYED)
Example #45
0
 def test_with_zero(self):
     """
     should return 0 when the given square has 0 played edges
     """
     unplay_all(board)
     self.assertEqual(placer._get_square_no_of_played(5, board), 0)
 def test_with_zero(self):
     """
     should return 0 when the given square has 0 played edges
     """
     unplay_all(board)
     self.assertEqual(placer._get_square_no_of_played(5, board), 0)