本文整理汇总了Python中term2048.board.Board.cells方法的典型用法代码示例。如果您正苦于以下问题:Python Board.cells方法的具体用法?Python Board.cells怎么用?Python Board.cells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类term2048.board.Board
的用法示例。
在下文中一共展示了Board.cells方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_canMove_no_empty_cell_can_collapse
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_canMove_no_empty_cell_can_collapse(self):
b = Board(size=2)
b.cells = [
[2, 2],
[4, 8]
]
self.assertTrue(b.canMove())
示例2: test_move_collapse_and_win
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_collapse_and_win(self):
b = Board(size=2, goal=4)
b.cells = [
[2, 2],
[0, 0]
]
b.move(Board.LEFT, add_tile=False)
self.assertTrue(b.won())
示例3: test_getLine
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
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)
示例4: test_move_collapse_chain_four_same_tiles
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_collapse_chain_four_same_tiles(self):
b = Board()
b.cells = [
[2, 2, 2, 2],
[0]*4,
[0]*4,
[0]*4
]
self.assertEqual(b.move(Board.LEFT, add_tile=False), 8)
self.assertSequenceEqual(b.getLine(0), [4, 4, 0, 0])
示例5: test_move_collapse_chain_line_left
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_collapse_chain_line_left(self):
b = Board()
b.cells = [
[0, 2, 2, 4],
[0]*4,
[0]*4,
[0]*4
]
self.assertEqual(b.move(Board.LEFT, add_tile=False), 4)
self.assertSequenceEqual(b.getLine(0), [4, 4, 0, 0])
示例6: test_move_collapse_chain_line_right2
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_collapse_chain_line_right2(self):
b = Board()
b.cells = [
[0, 4, 2, 2],
[0]*4,
[0]*4,
[0]*4
]
self.assertEqual(b.move(Board.RIGHT, add_tile=False), 4)
self.assertSequenceEqual(b.getLine(0), [0, 0, 4, 4])
示例7: test_move_collapse_chain_line
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_collapse_chain_line(self):
# from https://news.ycombinator.com/item?id=7398249
b = Board()
b.cells = [
[0, 2, 2, 4],
[0]*4,
[0]*4,
[0]*4
]
self.assertEqual(b.move(Board.RIGHT, add_tile=False), 4)
self.assertSequenceEqual(b.getLine(0), [0, 0, 4, 4])
示例8: test_move_collapse
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_collapse(self):
b = Board(size=2)
b.cells = [
[2, 2],
[0, 0]
]
b.move(Board.LEFT, add_tile=False)
self.assertSequenceEqual(b.cells, [
[4, 0],
[0, 0]
])
示例9: test_move_dont_add_tile_if_nothing_move2
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_dont_add_tile_if_nothing_move2(self):
b = Board()
b.cells = [
[8, 4, 4, 2],
[0, 2, 2, 0],
[0]*4,
[0]*4
]
self.assertEqual(b.move(Board.UP), 0)
self.assertEqual(len([e for l in b.cells for e in l if e != 0]), 6)
self.assertEqual(b.getLine(0), [8, 4, 4, 2])
self.assertEqual(b.getLine(1), [0, 2, 2, 0])
示例10: get_state_fake
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def get_state_fake(self, action):
b = Board()
b.cells=self.board.cells
b.move(action+1)
return b.cells
示例11: test_addTile
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_addTile(self):
b = Board(size=1)
b.cells = [[0]]
b.addTile(value=42)
self.assertEqual(b.cells[0][0], 42)
示例12: test_move_dont_add_tile_if_nothing_move
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
def test_move_dont_add_tile_if_nothing_move(self):
b = Board(size=2)
b.cells = [[2, 0],
[0, 0]]
b.move(Board.UP)
self.assertEqual(len([e for l in b.cells for e in l if e != 0]), 1)
示例13: test_move_add_tile_if_collapse
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [as 别名]
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)
示例14: test_getCol
# 需要导入模块: from term2048.board import Board [as 别名]
# 或者: from term2048.board.Board import cells [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)