推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
200
V2EX  ›  Python

写了一个命令行版的 2048

  •  
  •   200 · Mar 15, 2014 · 5947 views
    This topic created in 4577 days ago, the information mentioned may be changed or developed.
    原版: http://gabrielecirulli.github.io/2048/

    可以考虑跑些搜索 看看有没有好的策略啥的 (¬_¬)

    7 replies  •  2014-05-01 09:02:07 +08:00
    ericls
        1
    ericls  
       Mar 15, 2014
    这游戏一不小心玩儿了3个小时 我LGQ
    yangff
        2
    yangff  
       Mar 15, 2014 via Android
    早就有ai了。。
    jprovim
        3
    jprovim  
       Mar 16, 2014
    挑個毛病,使用AWSD操作,而且還需要輸入Enter。
    總體來說還是很好的。
    patricksong1993
        4
    patricksong1993  
       Mar 16, 2014
    2048升级版4096
    自带超快机器人
    http://patricksong1993.github.io/4096/
    rex
        5
    rex  
       Mar 18, 2014
    @jprovim @200
    可以使用

    ```
    def getkey():
    "get key press without Enter"

    import termios, sys, os

    fd = sys.stdin.fileno()
    old = termios.tcgetattr(fd)
    new = termios.tcgetattr(fd)
    new[3] = new[3] & ~TERMIOS.ICANON & ~TERMIOS.ECHO
    new[6][TERMIOS.VMIN] = 1
    new[6][TERMIOS.VTIME] = 0
    termios.tcsetattr(fd, TERMIOS.TCSANOW, new)
    c = None
    try:
    c = os.read(fd, 1)
    finally:
    termios.tcsetattr(fd, TERMIOS.TCSAFLUSH, old)
    return c
    ```

    代替sys.stdin.readline().strip().lower(),这样就不必 enter 了。
    rex
        6
    rex  
       Mar 18, 2014
    排版乱了。
    贴个链接试试

    https://gist.github.com/zhasm/9614482
    jprovim
        7
    jprovim  
       May 1, 2014
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   842 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 21:43 · PVG 05:43 · LAX 14:43 · JFK 17:43
    ♥ Do have faith in what you're doing.