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