本文整理汇总了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)
示例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)
示例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())
示例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())
示例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())
示例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())
示例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())
示例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())
示例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)
示例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())
示例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)
示例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())
示例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)
示例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)
示例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)