Behind the scenes: how six card games came from one kit
When we decided to add more card games, the plan was simple: do not build each one from scratch. Black Queen and Hearts already shared one server and one screen. This is how six more games fit on the same foundations, and what we learned doing it.
What every trick-taking game has in common
Spades, Euchre, Oh Hell, Call Break, Whist and Court Piece are all "trick" games: everyone plays a card, the best card wins, the winner leads next. What differs is small: whether there is bidding, how trump is chosen, what you must play, and how a hand is scored. So we wrote the common part once, a kit: dealing, who wins a trick, playing a card, and the decisions every bot makes (which card wins, which one to throw away). A game is then only its rules, written down in one file with the rules at the top in plain words.
The screen did not change
The same trick goes for the screen. The server sends the choices on offer (a bid, a suit, a discard) and the page just draws them, so the client has no bidding rules in it at all. A new game's page is a few dozen lines: its name, which chips to show, and how to summarise a hand. That is why all six games feel the same in your hand, and why a fix to one fixes them all.
How we know the bots are any good
A bot that plays illegal cards, or loses to random play, is worse than no bot. So each game's bot plays thousands of full games in the tests against players who throw random legal cards, and has to win clearly (the results are in the games post). Every test game also checks the rules at every step: nobody plays a card they do not hold, all 52 cards are always accounted for, and every game finishes. We tuned the Spades bidding by playing two versions of the bot against each other: bidding a little higher than the first guess beat the cautious version 165 to 85 over 250 games.
Things that went wrong
- A missing style sheet. The first screens had no styling on their bid buttons; the build was not including the shared styles. We caught it by playing the game on a phone-sized screen, not in a test.
- Hidden information. Court Piece deals only five cards before trump is named. The rest of the deck lives on the server and is never sent to anyone, and a test checks that the word never appears in what a player is sent.
- A sign-in page that said no. The community's sign-in page lets you restyle it with CSS, but only with a short list of allowed class names. Our first two attempts were rejected by Amazon with an error naming the one it did not like. Each failure also left an empty table and user pool behind that we had to clean up by hand.
Running it on a laptop
One thing that paid for itself: you can run the real game server on a laptop with no cloud account, using small in-memory stand-ins for the database and the connection service. A whole game of any of the six plays in the browser against bots before anything is deployed. The same trick runs the community, with a few sample threads.
What is next
Twenty-Nine is the next one (a bidding game where the trump suit stays secret until someone cannot follow suit), then games that are not about tricks, like Crazy Eights, and rummy. If you would like to help decide, the community has an Ideas board.