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


Python Board.slide方法代码示例

本文整理汇总了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}
开发者ID:ewilson,项目名称:py2048,代码行数:11,代码来源:board_test.py

示例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}
开发者ID:ewilson,项目名称:py2048,代码行数:12,代码来源:board_test.py

示例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}
开发者ID:ewilson,项目名称:py2048,代码行数:12,代码来源:board_test.py

示例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}
开发者ID:ewilson,项目名称:py2048,代码行数:12,代码来源:board_test.py

示例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}
开发者ID:ewilson,项目名称:py2048,代码行数:14,代码来源:board_test.py

示例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"
开发者ID:ewilson,项目名称:py2048,代码行数:24,代码来源:main.py


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