Ejemplo n.º 1
0
    def testWalkNoSplit(self):
        board = Board.create("""\
x 3|2 3|1 x
""")
        graph = BoardGraph()
        expected_states = set("""\
3|2 3|1
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 2
0
    def testWalkNoSplit(self):
        board = Board.create("""\
x 3|2 3|1 x
""")
        graph = BoardGraph()
        expected_states = set("""\
3|2 3|1
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 3
0
    def testWalkNoLoner(self):
        board = Board.create("""\
x 3 5 x
  - -
x 2 4 x

x 3|5 x
""")
        graph = BoardGraph()
        expected_states = set("""\
3 5
- -
2 4

3|5
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 4
0
    def ignoreWalkLast(self):
        """ Switching to NetworkX broke this. Not really used, so ignore for now.
        """
        board = Board.create("""\
3 x x
-
2 0|2

0|1 x
""")
        graph = BoardGraph()
        expected_last = """\
3 0|2 x
-
2 x 0|1
"""

        graph.walk(board)

        self.assertMultiLineEqual(expected_last, graph.last)
Ejemplo n.º 5
0
    def testWalkNoLoner(self):
        board = Board.create("""\
x 3 5 x
  - -
x 2 4 x

x 3|5 x
""")
        graph = BoardGraph()
        expected_states = set("""\
3 5
- -
2 4

3|5
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 6
0
    def ignoreWalkLast(self):
        """ Switching to NetworkX broke this. Not really used, so ignore for now.
        """
        board = Board.create("""\
3 x x
-
2 0|2

0|1 x
""")
        graph = BoardGraph()
        expected_last = """\
3 0|2 x
-
2 x 0|1
"""

        graph.walk(board)

        self.assertMultiLineEqual(expected_last, graph.last)
Ejemplo n.º 7
0
    def testWalkDown(self):
        board = Board.create("""\
x 3 x x x
  -
x 2 0|2 x

x 0|1 x x
""")
        graph = BoardGraph()
        expected_states = set("""\
3 x x
-
2 0|2

0|1 x
---
3 x x
-
2 0|2

x 0|1
---
3 x x x
-
2 0|2 x

x x 0|1
---
3 0|2
-
2 0|1
---
3 0|2 x
-
2 x 0|1
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 8
0
    def testWalkDown(self):
        board = Board.create("""\
x 3 x x x
  -
x 2 0|2 x

x 0|1 x x
""")
        graph = BoardGraph()
        expected_states = set("""\
3 x x
-
2 0|2

0|1 x
---
3 x x
-
2 0|2

x 0|1
---
3 x x x
-
2 0|2 x

x x 0|1
---
3 0|2
-
2 0|1
---
3 0|2 x
-
2 x 0|1
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 9
0
    def testWalkLeft(self):
        board = Board.create("""\
x 0|2

0|1 x
""")
        graph = BoardGraph()
        expected_states = set("""\
0|2

0|1
---
0|2 x

x 0|1
---
x 0|2

0|1 x
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
Ejemplo n.º 10
0
    def testWalkLeft(self):
        board = Board.create("""\
x 0|2

0|1 x
""")
        graph = BoardGraph()
        expected_states = set("""\
0|2

0|1
---
0|2 x

x 0|1
---
x 0|2

0|1 x
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)