예제 #1
0
    def test_first_move(self):
        board = QueuedBoard.create("""\
0|1

0|0
""", border=1)
        graph = AddingBoardGraph()
        expected = iter("""\
01l
###
0|1 x

x 0|0

###
01r
###
x 0|1

0|0 x

###
01h
###
0|0
===
0|1
""".split('\n###\n'))
        expected_moves = set(zip(expected, expected))

        moves = set(graph.generate_moves(board))

        self.assertEqual(expected_moves, moves)
예제 #2
0
    def test_walk(self):
        board = QueuedBoard.create("""\
1|6

0|0
""")
        graph = AddingBoardGraph()
        expected_states = set("""\
1|6

0|0
###
x 1|6

0|0 x
###
1|6 x

x 0|0
###
0|0
===
1|6
""".split('###\n'))

        states = graph.walk(board)
        self.assertEqual(expected_states, states)
예제 #3
0
    def test_display_empty_queue(self):
        state = """\
0 1|2
-
1 3|4
"""
        board = QueuedBoard.create(state)

        display = board.display()

        self.assertEqual(state, display)
예제 #4
0
    def test_create_without_queue(self):
        state = """\
0 1|2
-
1 3|4
"""
        expected_queue = []

        board = QueuedBoard.create(state)

        self.assertEqual(expected_queue, board.queue)
예제 #5
0
    def test_display(self):
        state = """\
0 1|2
-
1 3|4
===
4|5
5|6
"""
        board = QueuedBoard.create(state)

        display = board.display()

        self.assertEqual(state, display)
예제 #6
0
    def test_extra_dominoes(self):
        state = """\
0 1|2
-
1 2|0
===
0|0
1|1
"""
        expected_extras = [Domino(2, 2)]

        board = QueuedBoard.create(state, max_pips=2)

        self.assertEqual(expected_extras, board.extra_dominoes)
예제 #7
0
    def test_create(self):
        state = """\
0 1|2
-
1 3|4
===
4|5
5|6
"""
        expected_queue = [Domino(4, 5), Domino(5, 6)]

        board = QueuedBoard.create(state)

        self.assertEqual(1, board[0][0].pips)
        self.assertEqual(2, board[2][1].pips)
        self.assertEqual(expected_queue, board.queue)
예제 #8
0
    def test_get_from_queue(self):
        state = """\
0 1|2
-
1 2|0
===
0|0
1|1
"""
        board = QueuedBoard.create(state)
        expected_from_queue = Domino(0, 0)
        expected_queue = [Domino(1, 1)]

        from_queue = board.get_from_queue()

        self.assertEqual(expected_from_queue, from_queue)
        self.assertEqual(expected_queue, board.queue)