Nuwmorks: Three Doors Game
Happy Monday!
Introduction
In the popular game show Let's Make a Deal, there is a final round called the Big Deal. In the Big Deal, one or two contestants picked from one of three doors. One door had the "Big Deal" containing the biggest prize.
This game simulates a modified round of the Big Deal. You are tasked of choosing one of three doors, and the doors contain:
* $5,000 (not a real contest, this is for gaming purposes)
* A car
* A goat
Numworks Python Script: thedoorgame.py
https://my.numworks.com/python/ews31415/thedoorgame
Required modules: math, random, kandinsky, ion
# 2021-08-05 EWS
# Three Door Game
# based on Lets Make A Deal
from math import *
from random import *
from kandinsky import *
from ion import *
# set up the key function
def key():
while True:
if keydown(KEY_ONE):
return 1
if keydown(KEY_TWO):
return 2
if keydown(KEY_THREE):
return 3
# initial doors: indigo, fir green, orange
fill_rect(40,15,100,75,color(43,43,95))
fill_rect(140,15,200,75,color(34,139,34))
fill_rect(240,15,300,75,color(255,127,0))
# text, wheat
draw_string("1",70,45,color(245,222,179),color(43,43,95))
draw_string("2",170,45,color(245,222,179),color(34,139,34))
draw_string("3",270,45,color(245,222,179),color(255,127,0))
# prize setup
p=["\u0024 5,000","CAR","GOAT"]
l=[0,1,2]
w=[]
for i in range(3):
a=choice(l)
w.append(a)
l.remove(a)
# ask for a door
draw_string("Which door do you want?",40,120,color(0,0,0))
k=key()
if k==1:
ps=p[w[0]]
if k==2:
ps=p[w[1]]
if k==3:
ps=p[w[2]]
# the reveal
fill_rect(40,15,100,75,color(0,0,0))
fill_rect(140,15,200,75,color(0,0,0))
fill_rect(240,15,300,75,color(0,0,0))
# text, wheat
draw_string(p[w[0]],45,45,color(245,222,179),color(0,0,0))
draw_string(p[w[1]],145,45,color(245,222,179),color(0,0,0))
draw_string(p[w[2]],245,45,color(245,222,179),color(0,0,0))
draw_string("You win: "+ps,40,160,color(0,0,0))
Download the Python file here: https://drive.google.com/file/d/1yR8bBqmFwOeKZqBSgCVnoQkUcqDZzvu6/view?usp=sharing
Good luck!
Eddie
All original content copyright, © 2011-2021. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.