Play chess old school style

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

It’s not hard to count the number of bundled games in OS X (not counting games available via Terminal). The total count is one—Chess, which you’ll find in the Applications folder. While you can run this game easily enough in the Finder with a double-click, that really wouldn’t make for much of a hint. Instead, we’re going to take a look at how you can directly access the engine that runs Chess from Terminal.

Why would you want to do this? Honestly, I’m not sure—perhaps you’re a chess addict, playing for hours on end, and you’re tired of all the beautiful 3-D eye candy in the GUI version. Or maybe you’re a purist, and you prefer to enter your moves in algebraic chess notation, instead of dragging pieces around. Whatever the reason, here’s how to access the guts of Chess via Terminal.

Chess, it turns out, is powered by Sjeng, an open-source chess engine. To access Sjeng, open Terminal and type this command:

cd /Applications/

Once in that directory, you can launch Sjeng by typing (in OS X 10.5) ./sjeng.ChessEngine or (in OS X 10.4) ./sjeng. When the program launches, you’ll see some initialization output, and then a lovely rendition of a chess board done in ASCII—here’s a board after a few moves have been made (black pieces are denoted with a *, and are shown at the top of the board):

8 | *R | *N | *B |    | *K | *B |    | *R |
7 | *P | *P | *Q |    |    | *P | *P | *P |
6 |    |    |    |    | *P | *N |    |    |
5 |    |    |    | *P |    |    |    |    |
4 |    |    |    |  P |    |    |    |    |
3 |    |    |  P |    |    |    |    |    |
2 |  P |  P |    |    |  P |  P |  P |  P |
1 |  R |  N |    |  Q |  K |  B |  N |  R |

     a    b    c    d    e    f    g    h

Below the board you’ll see the Sjeng: command prompt; this is where you interact with the program. Chess moves are entered in standard chess notation, using the row and column labels shown at the edges of the board. An opening move for white’s pawn, for instance, would be d2d4. After you move (press Return to execute your move), Sjeng will ponder for a bit, then make its move. Continue in this manner until someone wins, or you grow bored of chess and decide to quit. (Type quit to do so.)

Sjeng has a number of options to control things such as the time per move and how well the computer plays; you can read about these options by typing help at the Sjeng command prompt.

I did run into one quirk when testing this hint—Sjeng would occasionally quit with a segmentation fault error, usually after a lot of thinking prior to making a move. I found a workaround for this problem by running Sjeng with root privileges. To do that, use this command:

sudo ./sjeng.ChessEngine

Enter your password when prompted, then press Return. When running with root privileges, I never had the program quit with the segmentation fault—I don’t know why, but it worked perfectly when run as root. I would only suggest using this solution, however, if you experience problems when using it in the normal non-root method.

Sjeng is a very capable computer opponent—well beyond my “I remember that the bishop moves diagonally” talent level. Playing it in Terminal may not be for everyone, but for this child of the ASCII gaming era, it brings back some memories.

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon