I built a CLI poker game that you don't need to install to play

filiph1 pts0 comments

How I built a CLI poker game that you don’t need to install to play

Filip Hráček /<br>text /

How I built a CLI poker game that you don’t need to install to play

I wrote a command-line poker game where you play against bots to train real-world skills. This article is about the why and the how.

To save you the hassle of installing the game, you can run it through ssh on my server:

ssh play@poker.filiph.net

This will drop you straight into the game. (You’ll have to type yes the first time to accept my server’s public key fingerprint.) But you can also install the game via brew or pub, or by downloading a standalone executable. More in the GitHub repo.

If you've been following me, you probably know I’m all about non-immersive games. The short of it is that:

Play has always been humanity’s greatest learning tool. It’s fantastic at teaching methods, concepts, ways to think. (I've written about this previously.)

BUT, like with everything, our natural fascination with games can be hijacked. A bunch of us spend time playing games that don’t actually give us all that much. Some of my fellow gamers will furiously disagree, but sinking significant amounts of time into any one game is a net negative. (But because some games are so damn optimized for engagement and addiction, it’s hard to resist.)

I say it’s more important than ever to build games that are honest, and don’t hoard your attention past their usefulness.

So far, I've built a text-based D&D simulator, a few web-based experiments, and these past few years I've been working on a 2D tactical mech simulator. I have a list of similar projects for the future.

The non-immersive game that’s the subject of this article, pokerd, has just been a short, welcome distraction from my regular contract work, and the aforementioned giant robot game.

Why command line?

This is not my first attempt at a modern command line game, and probably won’t be the last. Terminals are obviously never going to be mainstream, and they have severe performance and fidelity issues, but they have their advantages, too:

A significant audience of players use CLI every day. And they happen to be some of the smartest players out there.

A terminal game, just by being played in the terminal, can teach valuable skills and familiarity with one of the most powerful tools in existence: the command line.

The terminal imposes constraints that can be welcomed by some players. When playing a terminal game, you know that it won’t be taxing your computer all that much, that you can expect a relatively calm experience, and that you probably won’t need a mouse (so you can comfortably play on a laptop).

For some games, the ability to scroll up to see what happened previously is really useful.

Let’s face it, a terminal game makes it much easier for you to conceal the fact that you’re playing a game when in a meeting (unlike a 3D FPS, for example).

Why poker?

Despite its constraints, the terminal can support a variety of game genres. Strategy games, RPGs, arcades, puzzles, adventure games — you’ll find great examples of CLI games of any genre. So why poker?

Card games are familiar. You only need to show 10♣ or Q♥ and people get it.

Poker, in particular, is one of the most universally known card games.

The Texas Hold 'em variant of poker is the most popular for a reason. My favorite book on game design, Designing Games by Tynan Sylvester, spends a whole section on how brilliantly balanced Texas Hold 'em is — despite the book being primarily about video games.

In poker, the player only has about 5 verbs (that’s game designer lingo for “available actions”, roughly): check, call, raise, fold, all-in. This translates well to a keyboard-only interface (contrast and compare with chess, for example). And yet, even with this short list, the tactical decisions are almost infinitely rich.

Before you can play poker on any decent level, you have to learn some basics. The rules around betting, the hand rankings, the feel for what makes a strong hand and what makes a weak one. This, to me, calls for a “trainer”-type game, where you play on a computer to get some familiarity, but then really play with friends, in person. That’s the real goal of my project.

The TUI

Modern terminals can do a lot. Thousands of colors, Unicode characters and fast full screen refreshes can combine into an almost desktop-game-like experience. You could imagine a version of pokerd that shows large cards, animations, maybe even opponent faces.

But that’s not the direction I wanted to take. While it would be an interesting technical challenge, it would also clearly be using the wrong tool for the job.

Instead, I opted for a program that mostly just adds lines of text, without ever clearing the screen, so that you can scroll up to see the game’s history. I do use ANSI to rewrite stuff, but only for tiny menus (2 lines max).

I also mostly stay away from color. I tried using color to make cards stand out, and to differentiate suits...

game games poker play terminal built

Related Articles