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


Python Board.add方法代码示例

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


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

示例1: testAddCell

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [as 别名]
    def testAddCell(self):
        board = Board(4, 3)

        board.add(Cell(4), 1, 2)
        cell = board[1][2]

        self.assertEqual(4, cell.pips)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:9,代码来源:domino_puzzle_test.py

示例2: testAddDomino

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [as 别名]
    def testAddDomino(self):
        board = Board(4, 3)
        board.add(Domino(5, 6), 1, 2)

        pips = board[1][2].pips

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

示例3: testRemove

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [as 别名]
    def testRemove(self):
        board = Board(3, 4)
        domino1 = Domino(1, 5)
        board.add(domino1, 0, 0)

        board.remove(domino1)

        self.assertEqual([], board.dominoes)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:10,代码来源:domino_puzzle_test.py

示例4: testRemoveAndRotate

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [as 别名]
    def testRemoveAndRotate(self):
        board = Board(3, 4)
        domino1 = Domino(1, 5)
        board.add(domino1, 0, 0)

        board.remove(domino1)
        domino1.rotate(270)

        self.assertEqual(270, domino1.degrees)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:11,代码来源:domino_puzzle_test.py

示例5: testFlip

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [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())
开发者ID:binoliMhatre,项目名称:moonside,代码行数:15,代码来源:domino_puzzle_test.py

示例6: testDisplay

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [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)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:16,代码来源:domino_puzzle_test.py

示例7: testRotateAndAdd

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [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)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:18,代码来源:domino_puzzle_test.py

示例8: testMoveLeft

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [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)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:18,代码来源:domino_puzzle_test.py

示例9: testOffBoard

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [as 别名]
    def testOffBoard(self):
        board = Board(4, 3)

        with self.assertRaisesRegexp(BoardError,
                                     'Position 4, 0 is off the board.'):
            board.add(Domino(1, 2), 3, 0)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:8,代码来源:domino_puzzle_test.py

示例10: testOccupied

# 需要导入模块: from domino_puzzle import Board [as 别名]
# 或者: from domino_puzzle.Board import add [as 别名]
    def testOccupied(self):
        board = Board(4, 3)
        board.add(Domino(2, 3), 1, 0)

        with self.assertRaisesRegexp(BoardError, 'Position 1, 0 is occupied.'):
            board.add(Domino(1, 2), 0, 0)
开发者ID:binoliMhatre,项目名称:moonside,代码行数:8,代码来源:domino_puzzle_test.py


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