本文整理汇总了Python中term2048.board.Board.getCol方法的典型用法代码示例。如果您正苦于以下问题:Python Board.getCol方法的具体用法?Python Board.getCol怎么用?Python Board.getCol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类term2048.board.Board
的用法示例。
在下文中一共展示了Board.getCol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBoard
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import getCol [as 别名]
#.........这里部分代码省略.........
def test_addTile(self):
b = Board(size=1)
b.cells = [[0]]
b.addTile(value=42)
self.assertEqual(b.cells[0][0], 42)
# == .getCell == #
def test_getCell(self):
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)
示例2: test_getCol
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import getCol [as 别名]
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)
示例3: test_move_collapse_chain_col
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import getCol [as 别名]
def test_move_collapse_chain_col(self):
# from https://news.ycombinator.com/item?id=7398249
b = Board()
b.setCol(0, [0, 2, 2, 4])
b.move(Board.DOWN, add_tile=False)
self.assertSequenceEqual(b.getCol(0), [0, 0, 4, 4])