Hamsterdam Exchange

September 27, 2019

The last couple of days in Sleuthhounds: Cruise production I’ve been wrapping up work on one more sequence on the game’s critical path through the story. While the main story path has been “more or less” completed for some time, there were a couple of scenes that I knew needed something I just wasn’t sure what that something was and so those parts were intentionally left blank. Fortunately, this week I’ve figured out one of those scenes and have been working on its implementation.

In the scene in question, the player, as Jane Ampson, must join in a card game with two other characters and help one of those other characters to win the game. I felt that was an interesting and different challenge from the player simply trying to win or simply trying to lose against one other player.

I spent a bit of time researching different table top games, trying to find one that would work for the criteria I had in mind:

  • The game needed to be easy to explain to the player.
  • The game needed to be quick to play so that the player doesn’t get bogged down by it while conducting their investigation.
  • The game needed to be such that the player could actively help the character who needs to win and/or actively hinder the other character.
  • The game needed to have a simple set of decisions for the computer controlled players to make. I didn’t want to get into an extended development period building in-depth artificial intelligence for something that appears only once briefly within the broader Cruise game.
  • The game needed to be one that could be rigged in some way (e.g. by stacking a deck of cards) so that if random chance worked against the character who needed to win, the state of the game could be altered to allow that character to win without the player realizing that the state of the game was being altered.

[Hamsterdam Exhange - A work in progress.]
Hamsterdam Exhange - A work in progress.

After searching for an hour or two and not coming up with a game that met all my criteria, I took a step back to develop a game that would meet all the criteria. What I came up with is something called Hamsterdam Exchange.

The Rules

Two decks are formed, the “stock” deck from the cards ace through ten of clubs and diamonds, and the “modifier” deck from the cards ace through five of hearts and spades.

From the unused cards, each player is dealt two “certificate” cards face down. The objective of the game is to be the last player to still have a certificate card left.

Each round, each player is dealt a stock card and a modifier card, which they keep hidden from the other players, but can look at themselves.

The player to the left of the dealer goes first. In the “markets open” phase of the round they look at their stock card and decide if they want to keep it or not. The goal at the end of the round is to not have the lowest stock value. Whoever has the lowest stock value loses a certificate card.

If the player decides not to keep their stock card they trade it with the person to their left and keep the card they received face down. If the player is the dealer and they want to trade, they discard their current stock card and draw a new one from the top of the stock deck.

At the end of the “markets open” round, after everyone has had one opportunity to trade, all stock cards are turned face up to show the starting stock value of each player.

After the “markets open” phase the game then moves on to the “adjustment” phase. Again starting with the player to the dealer’s left, each player in turn may play any modifier card they have on either their own or another player’s stock card. Hearts (because they’re red and point down) subtract their face value from the value of the stock card. Spades (because they’re black and point up) add their face value to the value of the stock card. Modifiers are cumulative, so if three are played on one person they’re all added together with that player’s stock card.

A player does not have to play their modifier cards and the adjustment phase keeps going until all players pass consecutively. A player who already passed can decide to play their modifier cards so long as at least one other player has played a modifier in between.

At the end of the adjustment phase, whoever has the lowest stock total (or is tied for lowest) loses a certificate card. If they’ve lost both certificate cards then they are out of the game.

At the end of the round stock cards are returned to the stock deck, played modifier cards are returned to the modifier deck, and both decks are reshuffled. Players can keep any unplayed modifier cards for use in subsequent rounds of the game.

The Name

The loose thematic idea I had for the game was that it kinda, sorta represented the stock market. Each player receives a stock card and then during the course of the round they can trade that stock card and see that stock rise and fall.

Stock markets have been around for several hundred years. One of the earliest recognizable as a modern stock market was the Amsterdam Exchange. Given the anthropomorphic nature of Sleuthhounds Hamsterdam Exchange wasn’t much of a stretch.

Development

In implementing the card game I didn’t want to have to worry about all the visual presentation issues that would go with incorporating it into Cruise itself. Creating images for cards and the background and then fitting all that together with the game logic seemed like too big a morsel to bite off all at once. Instead, I threw together a quick and dirty Windows program to let me develop the backend game logic without having to worry about user interface issues.

[The quick and dirty Windows version.]
The quick and dirty Windows version.

Separating the game logic from the presentation made development significantly easier and I had a working version of the game done in less than a day, with two players controlled by the computer and myself able to inject the decisions for the human player through the barebones interface.

The nature of the game is such that an in-depth AI is not needed for the computer controlled players. Instead a series of simple decisions is “good enough” to have the computer play competently.

  • During the “markets open” phase, if a computer player has a stock of 5 or less (out of 10), they will trade it. The only exception is if the previous player already traded with them and took a lower valued card (in which case the computer player “knows” that it has a starting stock of greater value than at least one other player).
  • During the adjustment phase, a computer player passes if it has no modifier cards or its cumulative stock value is strictly greater than at least one other player.
  • If a computer players cumulative stock value is the lowest (or tied for the lowest) and the player has at least one modifier card, the computer checks to see if playing any combination of modifier cards will take them out of lowest position (or at least tie them for lowest position so they can take someone down with them if they’re going to lose). If so then the computer player will play the smallest positive card (spade) on themselves or the smallest negative card (heart) on the next lowest scoring player.

These simple decisions work well enough for my purposes to make it seem like the computer players are playing intelligently, at least in a normal game. The intention of the sequence in Cruise is that the human player help another character to win the game. However, there were two issues with that:

  1. After a couple of games, if the desired character has not won, Jane Ampson will talk to the third character to suggest letting the desired character win. How would the AI for the third character need to change to help further the goal of letting the desired player win?
  2. Given the random nature of how cards are distributed, it could be possible that even with two characters helping the desired winner, the desired winner simply wouldn’t be dealt cards good enough to win under any circumstances.

I started with the first issue, but very quickly got bogged down in the details of what kind of strategy the computer could employ whereby it would be helping another player to win. I ran into such challenges as the helping computer player needing to stay in the game as long as possible unless doing so caused the helpee player to lose a certificate card. Given the simple decision based nature of the “AI” a lot of special case exceptions started presenting themselves.

Setting that issue aside for a while, I turned my attention to ensuring the desired player had cards good enough to win the game with. The obvious answer there was to stack the deck in favour of the desired winner. A few simple scenarios emerged:

  • The desired winner would still receive a random stock card but it would be in the range 8 to 10 instead of 1 to 10.
  • The other players would also receive random stock cards but in the range 1 to 3.
  • The desired winner would receive a modifier card in the range of 4 to 5, unless no such cards existed. In which case they would receive a 3.
  • The other players would receive a modifier card in the range of 1 to 2, unless no such cards existed. In which case they would also receive a 3.

With only three players in the game and two certificate cards per player, the worst case scenario for a game is that it will take five rounds for two of the players to be eliminated. It’s possible for the cards to land in such a way that one of the desired losers holds onto their modifier cards until the final round, which would give them enough to overcome the base stock value of the desired winner. However, by that point the desired winner will have enough modifier cards of their own, not having reason to play them in preceding rounds, to overcome any modifications the desired loser could make.

The interesting development that came from stacking the deck was that it resolved the issue of determining a decision tree for the one computer player that needed to lose the game. By rigging the game in such a way that that player could not beat the desired winner, the decision tree still worked out that that player would try to push the human player out of the game.

The only other cheat I had to add in to guarantee victory for the desired winner was that during the “markets open” phase, if the non-desired winners (computer and human) decided to trade their starting stock card then instead of performing a real trade (for which they could get the 8 to 10 valued stock of the desired winner) they needed to silently receive a new card from the stock deck that was also in the range of 1 to 3.

As implemented in the actual Cruise game, the first two games of Hamsterdam Exchange that the player engages are played completely honestly with no rigging of the deck. The idea is to give the player a chance to realize they need to help the desired winner and to try to do so. However, if a third game needs to be played, then the deck stacking kicks in to ensure that the desired winner actually wins and that the Cruise game carries on. I’m still finishing up some of the visual aspects within Cruise itself, but Hamsterdam Exchange plays well and accomplishes what I need it to from a story point of view.