本文整理汇总了Python中domino_puzzle.Board.display方法的典型用法代码示例。如果您正苦于以下问题:Python Board.display方法的具体用法?Python Board.display怎么用?Python Board.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类domino_puzzle.Board
的用法示例。
在下文中一共展示了Board.display方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFillWithBacktrack
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFillWithBacktrack(self):
""" Force a backtrack.
This scenario will get to the following grid and then be forced to
backtrack.
x 3 4 x
- -
0 0 0 2
- -
0 0|1 0
"""
dummy_random = DummyRandom(
randints={(0, 4): [1, 0, 1, 1]}, # directions
choiceDominoes=[Domino(0, 0),
Domino(0, 1),
Domino(0, 2),
Domino(0, 3),
Domino(0, 4),
Domino(0, 5),
Domino(0, 4),
Domino(0, 5)])
board = Board(4, 3, max_pips=6)
expected_display = """\
0|4 0|5
0 0|3 2
- -
0 0|1 0
"""
board.fill(dummy_random)
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例2: testFillWithBacktrack
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFillWithBacktrack(self, mock_choose):
""" Force a backtrack.
This scenario will get to the following grid and then be forced to
backtrack, because the gaps are size 1 and 3: odd.
x 3 x x
-
0 0 x 2
- -
0 0|1 0
"""
mock_choose.side_effect = [[Domino(0, 0)],
[Domino(0, 1)],
[Domino(0, 2)],
[Domino(0, 3)],
[Domino(0, 3)],
[Domino(0, 3)],
[Domino(0, 3)],
[Domino(0, 4)],
[Domino(0, 5)]]
dummy_random = DummyRandom(
randints={(0, 3): [1, 0, 1, 1]}) # directions
board = Board(4, 3, max_pips=6)
expected_display = """\
0|4 0|5
0 0|3 2
- -
0 0|1 0
"""
board.fill(dummy_random)
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例3: testFlip
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFlip(self):
board = Board(3, 2, max_pips=6)
domino1 = Domino(1, 5)
expected_display = """\
x x x
5|1 x
"""
board.add(domino1, 0, 0)
domino1.flip()
self.assertMultiLineEqual(expected_display, board.display())
示例4: testDisplay
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testDisplay(self):
board = Board(4, 3)
board.add(Domino(5, 6), 1, 2)
expected_display = """\
x 5|6 x
x x x x
x x x x
"""
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例5: testFillWithRandomDomino
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFillWithRandomDomino(self):
dummy_random = DummyRandom(randints={(0, 4): [1, 1]}, # directions
choiceDominoes=[Domino(0, 5),
Domino(0, 2)])
board = Board(2, 2, max_pips=6)
expected_display = """\
5 2
- -
0 0
"""
board.fill(dummy_random)
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例6: testFillWithNoMatchesNext
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFillWithNoMatchesNext(self, mock_choose):
mock_choose.side_effect = [[Domino(0, 5)],
[Domino(0, 0), Domino(0, 1)]]
dummy_random = DummyRandom(randints={(0, 3): [1, 1]}) # directions
board = Board(2, 2, max_pips=6)
expected_display = """\
5 0
- -
0 1
"""
board.fill(dummy_random, matches_allowed=False)
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例7: testFillWithRandomDomino
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFillWithRandomDomino(self, mock_choose):
mock_choose.side_effect = [[Domino(0, 5)],
[Domino(0, 2)]]
dummy_random = DummyRandom(randints={(0, 3): [1, 1]}) # directions
board = Board(2, 2, max_pips=6)
expected_display = """\
5 2
- -
0 0
"""
board.fill(dummy_random)
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例8: testFillWithFlip
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testFillWithFlip(self):
dummy_random = DummyRandom(randints={(0, 4): [1, 1], # directions
(0, 1): [1, 0]}, # flips
choiceDominoes=[Domino(0, 0),
Domino(0, 1)])
board = Board(2, 2, max_pips=6)
expected_display = """\
0 0
- -
0 1
"""
board.fill(dummy_random)
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例9: testRotateAndAdd
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testRotateAndAdd(self):
board = Board(4, 3)
domino1 = Domino(5, 6)
domino1.rotate(-90)
board.add(domino1, 1, 2)
expected_display = """\
x 5 x x
-
x 6 x x
x x x x
"""
display = board.display()
self.assertMultiLineEqual(expected_display, display)
示例10: testMoveLeft
# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import display [as 别名]
def testMoveLeft(self):
board = Board(4, 3)
domino1 = Domino(5, 6)
board.add(domino1, 1, 2)
domino1.move(-1, 0)
expected_display = """\
5|6 x x
x x x x
x x x x
"""
display = board.display()
self.assertMultiLineEqual(expected_display, display)