本文整理汇总了Python中board.Board.board_from_array方法的典型用法代码示例。如果您正苦于以下问题:Python Board.board_from_array方法的具体用法?Python Board.board_from_array怎么用?Python Board.board_from_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.board_from_array方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testTranspose
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testTranspose(self):
b = Board()
b.board_from_array([[0,0,0,3],[2,0,0,2],[0,0,3,0],[2,0,2,2]])
b.transpose()
b2 = Board()
b2.board_from_array([[0,2,0,2],[0,0,0,0],[0,0,3,2],[3,2,0,2]])
self.assertEqual(str(b),str(b2))
示例2: testMoveUp
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testMoveUp(self):
b = Board()
b.board_from_array([[0,0,0,3],[2,0,0,2],[0,0,3,0],[2,0,2,2]])
b.move_up()
b2 = Board()
b2.board_from_array([[4,0,3,3],[0,0,2,4],[0,0,0,0],[0,0,0,0]])
self.assertEqual(str(b),str(b2))
示例3: testMoveRight2
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testMoveRight2(self):
b = Board()
b.board_from_array([[0,0,0,3],[2,0,0,2],[0,0,3,0],[2,0,2,2]])
b.move_right()
b2 = Board()
b2.board_from_array([[0,0,0,3],[0,0,0,4],[0,0,0,3],[0,0,2,4]])
self.assertEqual(str(b),str(b2))
示例4: testMoveLeft2
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testMoveLeft2(self):
b = Board()
b.board_from_array([[0,0,0,3],[2,0,0,2],[0,0,3,0],[2,0,2,2]])
b.move_left()
b2 = Board()
b2.board_from_array([[3,0,0,0],[4,0,0,0],[3,0,0,0],[4,2,0,0]])
self.assertEqual(str(b),str(b2))
示例5: testDoubleChange
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testDoubleChange(self):
b = Board()
b.board_from_array([[0,0,0,8],[0,0,0,4],[0,0,0,0],[0,0,0,4]])
b.move_down()
b2 = Board()
b2.board_from_array([[0,0,0,0],[0,0,0,0],[0,0,0,8],[0,0,0,8]])
self.assertEqual(str(b),str(b2))
示例6: testAddRandom2
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testAddRandom2(self):
random.seed(0)
b = Board()
b.make_move(b.LEFT)
b.make_move(b.RIGHT)
b2 = Board()
b2.board_from_array([[0,0,0,2],[2,0,0,2],[0,0,0,2],[0,0,0,0]])
self.assertEqual(str(b),str(b2))
示例7: testAddRandom
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testAddRandom(self):
random.seed(0)
b = Board()
b.move_left()
b.add_random()
b.move_right()
b2 = Board()
b2.board_from_array([[0,0,0,2],[0,0,0,2],[0,0,0,2],[0,0,0,0]])
self.assertEqual(str(b),str(b2))
示例8: testBoardFromArray
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testBoardFromArray(self):
arr = [[1,2,4,3],[0,0,2,3],[2,1,4,3],[2,3,4,9]]
b = Board()
b.board_from_array(arr)
prop = [[Square(1),Square(2),Square(4),Square(3)],
[Square(),Square(),Square(2),Square(3)],
[Square(2),Square(1),Square(4),Square(3)],
[Square(2),Square(3),Square(4),Square(9)]]
b2 = Board()
b2.board = prop
self.assertEqual(str(b), str(b2))
示例9: testTricky
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testTricky(self):
b = Board()
b.board_from_array([[0,0,0,2],[0,0,0,2],[0,0,0,2],[0,0,0,2]])
b.move_up()
b2 = Board()
b2.board_from_array([[0,0,0,4],[0,0,0,4],[0,0,0,0],[0,0,0,0]])
self.assertEqual(str(b),str(b2))
b.board_from_array([[0,0,0,4],[0,0,0,2],[0,0,0,2],[0,0,0,2]])
b.move_up()
b2.board_from_array([[0,0,0,4],[0,0,0,4],[0,0,0,2],[0,0,0,0]])
self.assertEqual(str(b),str(b2))
示例10: testNoMove
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board_from_array [as 别名]
def testNoMove(self):
b = Board()
b.board_from_array([[0,0,0,3],[0,0,0,2],[0,0,0,0],[0,0,0,0]])
ans = b.make_move(b.RIGHT)
self.assertEqual(ans,False)