写了一个命令行版的 2048

2014-03-15 00:00:32 +08:00
 200
原版: http://gabrielecirulli.github.io/2048/

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

https://gist.github.com/9549174
4565 次点击
所在节点    Python
7 条回复
ericls
2014-03-15 15:25:41 +08:00
这游戏一不小心玩儿了3个小时 我LGQ
yangff
2014-03-15 21:32:16 +08:00
早就有ai了。。
jprovim
2014-03-16 09:37:31 +08:00
挑個毛病,使用AWSD操作,而且還需要輸入Enter。
總體來說還是很好的。
patricksong1993
2014-03-16 23:44:49 +08:00
2048升级版4096
自带超快机器人
http://patricksong1993.github.io/4096/
rex
2014-03-18 14:14:31 +08:00
@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
2014-03-18 14:16:09 +08:00
排版乱了。
贴个链接试试

https://gist.github.com/zhasm/9614482
jprovim
2014-05-01 09:02:07 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/104377

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX