本文整理汇总了Python中board.Board.slide方法的典型用法代码示例。如果您正苦于以下问题:Python Board.slide方法的具体用法?Python Board.slide怎么用?Python Board.slide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.slide方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_slide_left_with_merge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import slide [as 别名]
def test_slide_left_with_merge():
b = Board()
b.tiles[(0,1)]= 4
b.tiles[(0,2)]= 4
b.tiles[(0,3)]= 4
b.slide('L')
assert b.tiles == {(0,0):8,(0,1):4}
示例2: test_board_slide_down_without_merge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import slide [as 别名]
def test_board_slide_down_without_merge():
b = Board()
b.tiles[(0,1)]= 2
b.tiles[(0,3)]= 4
b.tiles[(2,1)]= 3
b.tiles[(3,2)]= 8
b.slide('D')
assert b.tiles == {(2,1):2,(3,3):4,(3,1):3,(3,2):8}
示例3: test_board_slide_left_without_merge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import slide [as 别名]
def test_board_slide_left_without_merge():
b = Board()
b.tiles[(0,1)]= 2
b.tiles[(0,3)]= 4
b.tiles[(1,1)]= 2
b.tiles[(3,2)]= 8
b.slide('L')
assert b.tiles == {(0,0):2,(0,1):4,(1,0):2,(3,0):8}
示例4: test_board_slide_right_without_merge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import slide [as 别名]
def test_board_slide_right_without_merge():
b = Board()
b.tiles[(0,1)]= 2
b.tiles[(0,3)]= 4
b.tiles[(1,1)]= 2
b.tiles[(3,2)]= 8
b.slide('R')
assert b.tiles == {(0,2):2,(0,3):4,(1,3):2,(3,3):8}
示例5: test_slide_up_with_merge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import slide [as 别名]
def test_slide_up_with_merge():
b = Board()
b.tiles = {(0,0):4,(0,1):2,(0,2):2,
(1,0):4,(1,1):8,(1,2):2,(1,3):8,
(2,0):4,(2,1):8,(2,2):4,(2,3):8,
(3,0):4,(3,1):8,(3,3):2}
b.slide('U')
assert b.tiles == {(0,0):8,(0,1):2,(0,2):4,(0,3):16,
(1,0):8,(1,1):16,(1,2):4,(1,3):2,
(2,1):8}
示例6: display_new_board
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import slide [as 别名]
import os
from board import Board
from term_io import display, get_input
def display_new_board(b):
os.system('cls' if os.name == 'nt' else 'clear')
print display(b)
print b.score
if __name__ == '__main__':
b = Board()
success = b.place_random()
success = b.place_random()
while success:
display_new_board(b)
direction = get_input()
if b.slide(direction):
b.place_random()
success = b.check_for_moves()
else:
display_new_board(b)
print "Game Over"