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


Python Board.cells方法代码示例

本文整理汇总了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())
开发者ID:cychoi,项目名称:term2048,代码行数:9,代码来源:test_board.py

示例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())
开发者ID:cychoi,项目名称:term2048,代码行数:10,代码来源:test_board.py

示例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)
开发者ID:cychoi,项目名称:term2048,代码行数:12,代码来源:test_board.py

示例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])
开发者ID:JosephRedfern,项目名称:term2048,代码行数:12,代码来源:test_board.py

示例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])
开发者ID:JosephRedfern,项目名称:term2048,代码行数:12,代码来源:test_board.py

示例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])
开发者ID:JosephRedfern,项目名称:term2048,代码行数:12,代码来源:test_board.py

示例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])
开发者ID:cychoi,项目名称:term2048,代码行数:13,代码来源:test_board.py

示例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]
        ])
开发者ID:cychoi,项目名称:term2048,代码行数:14,代码来源:test_board.py

示例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])
开发者ID:cychoi,项目名称:term2048,代码行数:14,代码来源:test_board.py

示例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
开发者ID:choupi,项目名称:NDHUDLWorkshop,代码行数:7,代码来源:my2048.py

示例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)
开发者ID:cychoi,项目名称:term2048,代码行数:7,代码来源:test_board.py

示例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)
开发者ID:cychoi,项目名称:term2048,代码行数:8,代码来源:test_board.py

示例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)
开发者ID:cychoi,项目名称:term2048,代码行数:8,代码来源:test_board.py

示例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)
开发者ID:cychoi,项目名称:term2048,代码行数:8,代码来源:test_board.py


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