2048 in the terminal
github.com
github.com
Some kind of generalized 2048 game, with different or harder goals every "level" and some tweaked mechanics and we could see another one.
from term2048.game import Game
Game(goal=4096).loop()https://bitbucket.org/ElwinR/ipv4-defrag
I decided to give it a network admin theme, but don't be fooled, it's really the same game.
[1] http://ov3y.github.io/2048-AI/ [2] http://stackoverflow.com/q/22342854/1056032
Might add new strategy elements to the basic idea. You might not want to make a move, hoping the next blocks add to a block that's already on the board...maybe even "hint" where the next blocks will appear, but not the value. Tetris after all shows you the next block that will appear.
I noticed something that I think is incorrect behavior based on my playing of the original. If I have a row that has 2 - 2 - 4, when I press right, it goes straight to 8, rather than the behavior that I think is supposed to happen - press right once and get 4 - 4, press it again and get 8. A minor difference but does actually change the gameplay a bit.
Edit: I’m on this issue, currently trying to write a test to reproduce.
Edit 2: fixed!
https://github.com/brilee/games/blob/master/fibs.py
A short writeup is here: http://moderndescartes.com/essays/fibs
Overall this leads to a very different feel to the game.
Anything else I missed?
- Save game
- Save score
- Better UX (e.g. right now I need to refresh to start a new game) not UI and a bunch of other obvious stuff relevant to all native apps.
I don’t know what is Mobile Safari support for these, but you can play 2048 in your browser without Internet connection once you downloaded the page, and you can save game/scores in localStorage.
sudo easy_install pip
pip install term2048
“What’s pip?”
“A python package manager”
“How do I install it?”
“easy_install pip”
“What’s easy_install?”
“A python package manager”It's not so bad with the right tools. In particular, "virtualenv" lets you make "environments" for python packages so you can install these things without needing root access:
- Use your distro package manager to install virtualenv
- Make a new virtual environment with: virtualenv /tmp/vv
- "Enter" the environment: source /tmp/vv/bin/activate
- You now have "pip" so you can say pip install term2048
- Play
- rm -r /tmp/vv and log out; everything's all cleaned up now.
I didn't get around to write a good AI, but you can uncomment two lines in the main to play yourself. The interactive play is not colorful or as polished, but works the same way.
If you want to write a bot yourself, just call "play_bot(logic)", where "logic" is a function that takes a board state and returns a play. "play_bot" returns the highest piece created.
2048-as-a-monad version.
2048-as-a-jquery-plugin version.
I was clearly wrong in my interpretation
$ tail ~/.bash_history
open http://news.ycombinator.com
pip install term2048
term2048
term2048
term2048
term2048
term2048
term2048
term2048
pip uninstall term2048
Do you see what you've done?The original source is here: https://github.com/gabrielecirulli/2048/blob/master/js/game_...
(line 62)
I've been playing with GoLang lately and started to implement 2048 this week as a learning exercise. Nicely done!
EDIT: Still in the window! 2048 is not used by many projects. So essentially zero risk of a port conflict hosting this on a server with other services running.
Love text based games and bonus for being in the terminal. Btw, I know a few p.eople mentioned that it collapses 2-2-4 kind of combinations in one go and I noticed that too. But, you know what, I personally like this variation.
Edit: I’m on it.
Edit 2: I added a `--mode` option in the last version (0.1.7) to change the default colors mode. Use 'dark' on a dark background and 'light' on a light one. For now it only replaces dark blue with white on dark mode and yellow with black on light mode.
TL;DR: update with `pip install -U term2048` and use `term2048 --mode dark`.
oh wait...