Press Your Luck with Pygame

A game of chance for cash

Angelina
Random Thoughts
3 min readSep 8, 2020

--

https://i.gifer.com/WAuN.gif

Who doesn’t love game shows?

Recently, I made a pygame project entirely from scratch designed to act like the classic TV game show Press Your Luck.

In 1983, it first aired on CBS with host Peter Tomarken and lasted until 1986. It was revived in 2002 for GSN (The Game Show Network), which lasted until 2003. The most recent version, hosted by Elizabeth Banks, began airing in 2019 on ABC. One day, as I was watching a more current episode of the show, I got the idea to replicate Press Your Luck with pygame and some out of the box creativity!

Let’s start with the Rules of the game:

  • You get a variable number of spins to start (in the original, you earn spins by answering questions)
  • The spinner will display squares randomly until you press the stop button (in the show, it’s a cool board which too moves randomly)
  • If you land on a blue space, you earn the money displayed on the square, which is $1000 minimum and $1,000,000 maximum
  • Beware of Whammies! If you land on a Whammy square, you money goes down to zero
  • Four Whammies and it’s game over!
https://media.giphy.com/media/2mzOixOe0gfxWaxj23/giphy.gif

My main goal with this project was to make it feel like the real thing and have fun with Python and pygame. To enhance this, I added Whammy art by David Frangioso, as well as the show’s original theme, spin board music, and “Whammy!” sound effect.

When it came to rewards, I decide to devise my own probability-based random number generation system. It spawns a number between 1 and 1000, and outputs a prize based on this number.

As the prize gets bigger, the chance of winning it gets smaller. For example, there’s a 37% chance of $1000 (i.e. if the randomly generated number is one of 370 specific numbers, the reward is $1000), but only a 0.1% chance of getting a million dollars. In addition to these rewards, there’s a 25% chance of a getting a Whammy.

def spinReward() -> int: # returns reward 
r = random.randint(1,1000)
if r >= 1 and r <= 369:
return 1000
if r >= 370 and r <= 559:
return 2000
if r >= 560 and r <= 659:
return 2500
if r >= 660 and r <= 704:
return 5000
if r >= 705 and r <= 725:
return 10000
if r >= 725 and r <= 734:
return 20000
if r >= 735 and r <= 739:
return 25000
if r >= 740 and r <= 743:
return 50000
if r >= 744 and r <= 745:
return 100000
if r >= 746 and r <= 747:
return 250000
if r >= 748 and r <= 749:
return 500000
if r == 750:
return 1000000
else:
return 0 # Whammy!

Randomness is power!

https://media.giphy.com/media/dvZMhSfEPRN1edBwMc/giphy.gif

If you would like to try my program, feel free to checkout this github repo run it. (But keep in mind, it’s licensed!)

My demonstration below:

https://www.youtube.com/watch?v=A3Rm8XEWt18

--

--