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