- Reset Game
- Book
- BASIC
-
Acey Ducey
Original Resources
Download the original BASIC code. Check out the original page the text below was taken from in the Book.
Instructions From the Book
"This is a simulation of the Acey Ducey [sic] card game. In the game, the dealer (the computer) deals two cards face up. You have an option to bet or not to bet depending on whether or not you feel the next card dealt will have a value between the first two.
Your initial money (Q) is set to $100; you may alter Statement 110 if you want to start with more or less than $100. The game keeps going on until you lose all your money or interrupt the program.
The original program author was Bill Palmby of Prairie View, Illinois."
Modifications For This Version
In the original, of course, the interaction was all command line text. In this version, I've decided to go with minimal "graphics" to display the card. I've also added an additional feature of the game. If your winnings happen to reach $5000 (or more), you will "break the bank" and the game ends. It's surprisingly difficult to get there.
In the original game, if you choose to not bet, the game calls you a chicken. My version is a little more creative with its insults.
Technical Stuff
This is the first game from the book that I wrote for this project. It started as a brief discussion with my PHP students to see how they would solve the problem of keeping track of what cards were played, etc. The discussion inspired be to build the game in PHP as a challenge. Because the game is written in PHP, we're using POST and SESSION variables, server pings, and page reloads.
The Future
Many of the games in the book have a guessing component where the computer has a stored value that needs to be kept hidden from the user. Writing those programs in JavaScript allows savvy users to be able to access the secret information. However, in the case of Ace Ducey, none of the information needs to be hidden, so JavaScript is a better way to go for this one. Because of this, there will likely be a future JavaScript version to replace this one.
Additionally I will, likely, modify the game to have the correct probabilities in the JavaScript version. See the probability notes below for details.
Incorrect Probabilities
Currently this code (and the B.A.S.I.C. code) do not account for the fact that in a real deck of cards, if an Ace and a King are showing, there are only 3 Aces and 3 Kings left in the deck that can be turned up for the third card. This changes the probability of winning. The random cards drawn by the computer are just a random number between 1 and 13. Every card has a 1 in 13 chance of showing up every time.
If an Ace is the first card, and a King is the second card, currently the probability that you'll lose (i.e., the third card is an Ace or a King) is 2/13 (about a 15% probability). Whereas if we were using a regular deck, the probability would be 6 (3 Aces and 3 Kings) out of 50 cards (i.e., the remainder of the deck after the first two cards were drawn). This is only a 12% probability you will lose. It's not much, but it's better.
Other Probability Thoughts
For the not so faint at heart, here's a crazy article on the mathematics of the game. Without needing to fully understand the insanity of that article, after playing this game hundreds (maybe thousands) of times, I began to realize how the probabilty of losing, in general is quite high. We saw with A and K that the probability of losing is 15%. But just by changing to A and Q, the probability of losing goes up to 23%. A and J: 30%, A and 10: 38%, A and 9: 46%, A and 8: 53%, etc. It only gets worse.
Also consider that we're looking at best-case scenarios where the first card is an Ace. If the first card is a two, it's even worse. If the spread between the cards is 7 cards or fewer, the probability is over 50% that you will loose. Compound this with the fact that most of the spreads between any two cards is a number that's 7 or smaller. The probability is definitely not in your favor. Now that you know you'll loose most of the time . . .
Enjoy Acey Ducey!