For our third game, we will look at Ninety-Eight, a simple game from the adding genre of care games, which also includes Cribbage. Sometimes called Ninety-Nine, this game is alternately described as a great game for kids to learn addition, or a great drinking game for adults. It’s simple core mechanism has been expanded into a few commercial games such as O’NO 99, BOOMO, and 5 Alive.
First, let’s see how you play!
Rules
Shuffle a standard deck of cards, and deal four cards face down to each player. Players then take turns playing one card to the top of a discard pile and drawing a replacement from the deck. The goal is to keep the total value of all cards in the discard pile less than or equal to 98. Ace through 9 are worth their number value (Ace equals 1). The Jack and Queen are worth 0 points, while the ten is worth -10 points. The King sets the value of the discard pile to 98. The player who makes the total above 98 loses the game.
RECYCLE Coding
To illustrate how we encode these rules computationally, we will walk through in detail the RECYCLE code for Ninety-Eight. Ninety-Eight is one of the smallest games in terms of rules and coding that we will examine.
First, we create the players and the (currently irrelevant) teams, followed by the standard French deck of 52 cards.
The point values of the Ace through 9 cards are assigned in a PointMap. The other card ranks
are left out, and will return a value of 0 when this 'PRECEDENCE
map is used.
To start off the game, each player is dealt 4 cards from the face-down STOCK
to put in their
private HAND
location.
There is only one stage in Ninety-Eight, which cycles through each player in turn until
someone has caused the total point value of the discard pile to go over 98. The
total value of the discard PILE
will be tracked in an integer storage called POINTS
.
In this stage, each player is free to choose any of the cards in their HAND
location to
move to the top of the discard PILE
location.
After a player’s turn, the game updates the POINTS
storage based on the card played.
If it was an Ace through 9, then the value is simply incremented. If it was a King,
then the value is set to 98. If it was a ten, then the value is decremented by 10.
One card is then dealt to the current player from the STOCK
.
Finally, if the value of POINTS
is above 98, the current player is declared the loser
by decreasing their SCORE
.
At the end of the game, we look at the scores of the players to determine the winner. These numbers will be either 0 if you won, and -1 if you lost.
Up Next
Ninety-eight is simple, but is it too simple to be interesting?
In the next post, we’ll ask, does the player have choices, and is there opportunity for strategy? We’ll also look at the way AI players affect the length of the game for Ninety-Eight.
Image courtesy of https://en.wikipedia.org/wiki/Ninety-nine_(addition_card_game)#/media/File:King_playing_cards.jpg.
comments powered by Disqus