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


Python Board.setLine方法代码示例

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


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

示例1: test_move_collapse_with_empty_cell_in_between2

# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import setLine [as 别名]
 def test_move_collapse_with_empty_cell_in_between2(self):
     b = Board(size=3)
     b.setLine(0, [2, 0, 2])
     b.move(Board.LEFT, add_tile=False)
     self.assertSequenceEqual(b.getLine(0), [4, 0, 0])
开发者ID:cychoi,项目名称:term2048,代码行数:7,代码来源:test_board.py

示例2: TestBoard

# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import setLine [as 别名]

#.........这里部分代码省略.........
        x, y = 3, 1
        v = 42
        self.b.cells[y][x] = v
        self.assertEqual(self.b.getCell(x, y), v)

    # == .setCell == #
    def test_setCell(self):
        x, y = 2, 3
        v = 42
        self.b.setCell(x, y, v)
        self.assertEqual(self.b.cells[y][x], v)

    # == .getLine == #
    def test_getLine(self):
        b = Board(size=4)
        l = [42, 17, 12, 3]
        b.cells = [
            [0]*4,
            l,
            [0]*4,
            [0]*4
        ]
        self.assertSequenceEqual(b.getLine(1), l)

    # == .getCol == #
    def test_getCol(self):
        s = 4
        b = Board(size=s)
        l = [42, 17, 12, 3]
        b.cells = [[l[i], 4, 1, 2] for i in xrange(s)]
        self.assertSequenceEqual(b.getCol(0), l)

    # == .setLine == #
    def test_setLine(self):
        i = 2
        l = [1, 2, 3, 4]
        self.b.setLine(i, l)
        self.assertEqual(self.b.getLine(i), l)

    # == .setCol == #
    def test_setLine(self):
        i = 2
        l = [1, 2, 3, 4]
        self.b.setCol(i, l)
        self.assertEqual(self.b.getCol(i), l)

    # == .getEmptyCells == #
    def test_getEmptyCells(self):
        self.assertEqual(len(self.b.getEmptyCells()), Board.SIZE**2 - 2)

    def test_getEmptyCells_filled(self):
        b = Board(size=1)
        b.setCell(0, 0, 42)
        self.assertSequenceEqual(b.getEmptyCells(), [])

    # == .move == #
    def test_move_filled(self):
        b = Board(size=1)
        b.setCell(0, 0, 42)
        b.move(Board.UP)
        self.assertSequenceEqual(b.cells, [[42]])
        b.move(Board.LEFT)
        self.assertSequenceEqual(b.cells, [[42]])
        b.move(Board.RIGHT)
        self.assertSequenceEqual(b.cells, [[42]])
        b.move(Board.DOWN)
开发者ID:cychoi,项目名称:term2048,代码行数:70,代码来源:test_board.py

示例3: test_move_collapse_triplet2

# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import setLine [as 别名]
 def test_move_collapse_triplet2(self):
     b = Board(size=3)
     b.setLine(0, [2, 2, 2])
     b.move(Board.RIGHT, add_tile=False)
     self.assertSequenceEqual(b.getLine(0), [0, 2, 4])
开发者ID:cychoi,项目名称:term2048,代码行数:7,代码来源:test_board.py


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