当前位置: 首页>>代码示例>>Python>>正文


Python Board.create方法代码示例

本文整理汇总了Python中domino_puzzle.Board.create方法的典型用法代码示例。如果您正苦于以下问题:Python Board.create方法的具体用法?Python Board.create怎么用?Python Board.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在domino_puzzle.Board的用法示例。


在下文中一共展示了Board.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testEqualWithGap

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testEqualWithGap(self):
        state = """\
0|4 0|5

0 x x 2
-     -
0 0|1 0
"""
        board1 = Board.create(state)
        board2 = Board.create(state)

        eq_result = (board1 == board2)
        neq_result = (board1 != board2)
        self.assertTrue(eq_result)
        self.assertFalse(neq_result)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:17,代码来源:domino_puzzle_test.py

示例2: testDisconnectedBeforeCapture

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testDisconnectedBeforeCapture(self):
        """ Board must be connected after move and after capture.

        Here, move 62L is disconnected after the move, but connected after
        the capture removes most of the dominoes. Test that the move is still
        not allowed.
        """
        board = Board.create("""\
x x x x 5
        -
x x 6|2 3

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

6|6 2|4 x
""".split('---\n'))

        states = graph.walk(board)

        self.assertEqual(expected_states, states)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:28,代码来源:domino_puzzle_test.py

示例3: testIsConnected

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testIsConnected(self):
        state = """\
1 0|2 x x
-
0 0|4 0|3
"""
        board = Board.create(state)

        self.assertTrue(board.isConnected())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:11,代码来源:domino_puzzle_test.py

示例4: testIsNotConnected

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testIsNotConnected(self):
        state = """\
1 0|2 x x
-
0 x x 0|3
"""
        board = Board.create(state)

        self.assertFalse(board.isConnected())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:11,代码来源:domino_puzzle_test.py

示例5: testHasNoLoner

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testHasNoLoner(self):
        state = """\
1 0 x 1|3
- -
0 2 x 0|3
"""
        board = Board.create(state)

        self.assertFalse(board.hasLoner())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:11,代码来源:domino_puzzle_test.py

示例6: testHasLoner

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testHasLoner(self):
        state = """\
1 0 x 1|2
- -
0 2 x 0|3
"""
        board = Board.create(state)

        self.assertTrue(board.hasLoner())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:11,代码来源:domino_puzzle_test.py

示例7: testHasMatch

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testHasMatch(self):
        state = """\
1 2
- -
0 0
"""
        board = Board.create(state)

        self.assertTrue(board.hasMatch())
开发者ID:donkirkby,项目名称:donimoes,代码行数:11,代码来源:domino_puzzle_test.py

示例8: testHasNoMatch

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testHasNoMatch(self):
        state = """\
1 0
- -
0 2
"""
        board = Board.create(state)

        self.assertFalse(board.hasMatch())
开发者ID:donkirkby,项目名称:donimoes,代码行数:11,代码来源:domino_puzzle_test.py

示例9: testNoSolution

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testNoSolution(self):
        graph = CaptureBoardGraph()
        board = Board.create("""\
6|2 3
    -
2|4 5
""")
        graph.walk(board)

        self.assertRaises(NetworkXNoPath, graph.get_solution)
开发者ID:donkirkby,项目名称:donimoes,代码行数:12,代码来源:domino_puzzle_test.py

示例10: testCreateVertical

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testCreateVertical(self):
        state = """\
1 0|2
-
0 x x
"""

        board = Board.create(state)

        self.assertMultiLineEqual(state, board.display())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:12,代码来源:domino_puzzle_test.py

示例11: testDifferentAlignment

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testDifferentAlignment(self):
        state1 = """\
0|4 0|5

0 0|3 2
-     -
0 0|1 0
"""
        state2 = """\
0|4 0|5

0 0 3 2
- - - -
0 0 1 0
"""
        board1 = Board.create(state1)
        board2 = Board.create(state2)

        self.assertNotEqual(board1, board2)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:21,代码来源:domino_puzzle_test.py

示例12: testCreateRightEdge

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testCreateRightEdge(self):
        state = """\
x 0|2

0|1 x
"""

        board = Board.create(state)

        self.assertMultiLineEqual(state, board.display())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:12,代码来源:domino_puzzle_test.py

示例13: testFindNoMatch

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testFindNoMatch(self):
        state = """\
1 0
- -
0 2
"""
        board = Board.create(state)
        matches = board.findMatches()
        expected_matches = []

        self.assertEqual(expected_matches, matches)
开发者ID:donkirkby,项目名称:donimoes,代码行数:13,代码来源:domino_puzzle_test.py

示例14: testCreate

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testCreate(self):
        state = """\
0|2 x

0|1 x
"""

        board = Board.create(state)
        display = board.display()

        self.assertMultiLineEqual(state, display)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:13,代码来源:domino_puzzle_test.py

示例15: testHasEvenGapsOneEvenGap

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import create [as 别名]
    def testHasEvenGapsOneEvenGap(self):
        state = """\
4|5 6 0
    - -
1 2 1 5
- -
0 3 x x
"""
        board = Board.create(state)
        has_even_gaps = board.hasEvenGaps()

        self.assertTrue(has_even_gaps)
开发者ID:donkirkby,项目名称:donimoes,代码行数:14,代码来源:domino_puzzle_test.py


注:本文中的domino_puzzle.Board.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。