What | 2048.tcl |
Where | https://github.com/dbohdan/2048.tcl |
Description | The game of 2048 implemented in Tcl. Can be played on *nix and Windows in a terminal/command line window. |
Platforms | Linux, *BSD, Windows, OS X (presumably). |
Prerequisites | Tcl 8.5 or newer. |
Updated | 2017-07-21 (version 0.4.0) |
License | MIT |
Screenshot edit
[ 8][ 2][ 2]......
........................
............[ 2*]......
........................
Move (hjkl)?
The star indicates a new tile.
Download edit
Download as 2048.tcl
curl -s https://raw.githubusercontent.com/dbohdan/2048.tcl/master/2048.tcl
| tee 2048.tcl && chmod +x 2048.tcl Install to /usr/local/bin/
curl -s https://raw.githubusercontent.com/dbohdan/2048.tcl/master/2048.tcl
| sudo tee /usr/local/bin/2048 && sudo chmod +x /usr/local/bin/2048 Discussion edit
dbohdan 2014-06-12: Here's a text-only version with non-greedy movement. The implementation has a slight list processing bent.
Update: Fixed just moving a 2 tile onto a new 2* tile not being recognized as a valid move. Refactored
TWAPI input support contributed by
pooryorick and added similar for *nix (see:
Reading a single character from the keyboard using Tcl).
PYK 2014-06-15: I thought it would be fun to have a random play mode, which led to other ideas, including making it more game-like by clearing the screen between plays. That in turn led to a need to aggregate
puts commands for speedier rendering over a high-latency connection. Also switched to event-driven input to allow user to pause random-play mode or toggle back to normal play. Added prompt to select board size, as well as a report of turns taken at end of game. Did more work on terminal control. Made the code more library-like so that a
GUI skin might be feasible in the future. dbohdan, if you'd rather keep your own version here without my modifications, just revert the changes and I'll fork my changes to a different page.
dbohdan 2014-06-15: Thanks for asking! I don't mind your changes at at all; it's great you made the code more modular. That said, I don't think a wiki page is quite the right way for people to collaborate on a piece of code already this long and growing, especially since it may benefit from being split into multiple files later.
Since I already had all my revisions in a
Git repo I put it on GitHub under the MIT license:
https://github.com/dbohdan/2048-tcl![](/ext.png)
. Your latest change is pretty major, so I didn't commit it myself. If you have an account fork it and issue a pull request so that you get proper credit for your contribution. If you don't use GitHub an alternative like Bitbucket or
Chisel is also an option (although I have very limited experience with
Fossil).
dbohdan 2014-06-16: Great! I have merged your commit. Make sure to "watch" the repository if you want to get notified of my (or other contributors', should there be any) changes to the repo.
I found a bug where you could cheat and skip turns and fixed it just now (see the closed issue). WRT that, if we keep the source on this page but don't keep it in sync with the repository as it stands it won't be immediately clear if it is up to date. To mitigate this I added a version number in the format of MAJOR.MINOR.PATCH; bump MINOR for features, PATCH for bugfixes.