An implementation of 2048 created using LC-3, an educational programming language.
To execute LC-3 programs, they must be assembled into an object file and loaded into a simulator. The tools necessary to do this can be found on McGraw Hill's website for the LC-3. The following instructions are for *nix operating systems, but the concepts are similar for Windows.
-
Download or compile the lc3tools. If you're using Mac, you can easily install them via my Homebrew tap:
$ brew tap rpendleton/homebrew-tap $ brew install lc3tools
Alternatively, you can compile them yourself.
$ unzip lc3tools_v12.zip $ cd lc3tools $ ./configure --installdir /path/to/install/dir $ make $ make install
-
After you've installed the lc3tools, you need to download the project and assemble the object file. You can do this using
lc3as
.$ git clone https://github.com/rpendleton/lc3-2048.git $ cd lc3-2048 $ lc3as 2048.asm
-
Now that the object file is ready, all that's left is to load it into the simulator.
$ lc3sim 2048.obj ... (lc3sim) c Control the game using WASD keys. Are you on an ANSI terminal (y/n)? y +--------------------------+ | | | | | | | 2 | | | | 2 | | | | | | | +--------------------------+
After starting the simulator and loading the object file, pressing
c
will start the program. The game takes advantage of ANSI terminal features, so if you're using a *nix operating system, make sure to pressy
when prompted. Otherwise, pressn
to avoid seeing garbage escape sequences.