coding-horror / basic-computer-games

An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common MEMORY SAFE, SCRIPTING programming languages. See https://coding-horror.github.io/basic-computer-games/
The Unlicense
10.84k stars 1.33k forks source link

Python Acey-Ducey has a "1" card instead of the "10" #869

Closed mckeed closed 1 year ago

mckeed commented 1 year ago

The set of cards in Acey-Ducey is supposed to be 2-10,J,Q,K,A. The Python version has 1-9,J,Q,K,A.

coding-horror commented 1 year ago

how can we fix this? pull request?

unquietwiki commented 1 year ago

I was looking at this just now, and noticed some things...

  1. The non-OO Python version relies on a dictionary for the cards. That's easily updated to correct for the problem here.
  2. Both versions rely on random.shuffle, something the other ports don't seem to do (including the Pascal -> Nim port I just did). Now the OO Python version does something cool by introducing suites, so the shuffle works there; it's otherwise near impossible to win on the non-OO version. I'd consider that a bug.
  3. In the OO version, "chickening out" causes the game to reset; so that's another bug to tackle.

Since I need Python practice anyway, I could make the suggested repairs; but don't want to make major changes without consent here.

coding-horror commented 1 year ago

sounds good to me, go for it! 🙌

unquietwiki commented 1 year ago

Hey @coding-horror , there's one other question I have. My Nim port, plus some of the other ports, use >= and <= for the win range. The Python versions use < & >; the BASIC version seems to be a mix. What are your thoughts?

unquietwiki commented 1 year ago

I fixed the logic in the OO version to not end on a 0 bet. Regarding my previous question, I actually found the rules for this game, and apparently matching one of the numbers is supposed to double the bet; something I don't think the original version was doing. So it would seem that >= and <= are acceptable.

https://en.wikipedia.org/wiki/Yablon#Rules