推荐学习书目
› 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 · 6103 views
    This topic created in 4626 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
    ericls
    Mar 15, 2014
    1
    这游戏一不小心玩儿了3个小时 我LGQ
    yangff
    yangff
    Mar 15, 2014 via Android
    2
    早就有ai了。。
    jprovim
    jprovim
    Mar 16, 2014
    3
    挑個毛病,使用AWSD操作,而且還需要輸入Enter。
    總體來說還是很好的。
    patricksong1993
    patricksong1993
    Mar 16, 2014
    4
    2048升级版4096
    自带超快机器人
    http://patricksong1993.github.io/4096/
    rex
    rex
    Mar 18, 2014
    5
    @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
    rex
    Mar 18, 2014
    6
    排版乱了。
    贴个链接试试

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