## Saturday, June 16, 2018

### Casio fx-CG 50 and HP Prime: The Price is Right Wheel Simulation

Casio fx-CG 50 and HP Prime: The Price is Right Wheel Simulation

Introduction

On the very famous game show, The Price Is Right, currently enjoying its fifth decade in its current run on television (1972-present), the hour long game show is divided into three segments.  The first two segments are played this way:

* An item up for bid is presented to four contestants who directly called from the audience.  Whoever gets closest to the actual retail price without going over wins the prize and plays a pricing game. This cycle occurs three times.

* The three winners play in a Showcase Showdown, where they spin a wheel.  The goal is obtain a score closest to one dollar without going over.  The winner advances to the final Showcase round.

The third segment is the Showcase round played by the two winners of the Showcase Showdown, where prize packages worth thousands of dollars are at stake.

This blog will present a simulation of the Showcase Showdown.  Like the game show, the amounts are shown in cents, where 100 represents one dollar.

Single Spin Simulation:  Casio fx-CG 50

This program simulates a single spin.  The spin starts on the dollar (100) space.  The space that the pointer is in red with arrows pointed at it.  You can use the program on monochrome screens if you wish, just not type the color commands (Black, Red).

Casio fx-CG50 Program TRIPWHL1

“EWS 2018-06-12”
{100,15,80,35,60,20,40,
75,55,95,50,85,30,65,10,
45,70,25,90,5}→List 1
1 → P
For 1 → K To RanInt#(20, 60)
ClrText
MOD(P, 20) → P
MOD(P+18, 20) → A
MOD(P+19, 20) → B
MOD(P, 20) → C
MOD(P+1, 20) → D
MOD(P+2 ,20) → E
A = 0 20 → A
B = 0 20 → B
C = 0 20 → C
D = 0 20 → D
E = 0 20 → E
Black Locate 5, 2, List 1[E]
Black Locate 5, 3, List 1[D]
Red Locate 5, 4, List 1[C]
Red Locate 10, 4 “
Black Locate 5, 5, List 1[B]
Black Locate 5, 6, List 1[A]
MOD(P+1, 20) → P
.1 + .4 K → T
For .1 → I To T Step .1
Next
Next

Note:  The lines .1+.4K and the second For loop that follows it is to simulate the wheel that slows down as it spins.

Now, if you want a complete simulation, check out the HP Prime program TPIRWHEEL.

A Showcase Showdown Round Simulation:  HP Prime Program TPIRWHEEL

The program offers two modes:

2 Player Spinoff:  This is a one spin playoff between two players.

3 Player Normal:  This is a normal game between three players.  Each player may have up to two spins.  If the score exceeds 1 dollar, the player is out, and given a final score of 0.

When entering the names, you do not need to worry about entering the quotes.

Bonus Spins

Should a player get 1 dollar in one spin or their score from two spins add up to 1 dollar, then the player gets a bonus spin and wins \$1,000.  The bonus spin always starts from the 5 cent position.  Unlike the game show, all bonus spins are taken immediately.  Landing on the green 5 cents and 15 cents spaces wins \$10,000, while landing on the red dollar space on the bonus spins wins \$25,000.  The amount on the bonus spin does not affect the player’s final score.

End of the Game

The end of the game will lists the players and their final scores.

HP Prime Program TPIRWHEEL
The program is over 10,000 bytes in memory.

sbr1(); // subroutine - wheel

EXPORT TPIRWHEEL()
BEGIN
// EWS 2018-06-09
// The Price Is Right Showcase Showdown
// Simulator - Official Version
// bonus spins starts immediately
// 2 player spinoff mode (manual)

// Setup
LOCAL n,k,j,t,str1,str2,str3;
LOCAL str4,m,b;
CHOOSE(n,"Number of Players",
{"2 Player Spinoff",
"3 Player Normal"});
n:=n+1;
LOCAL players:={};
LOCAL scores:=MAKELIST(0,X,1,n);
LOCAL bonuses:=MAKELIST(0,X,1,n);

// Names
FOR k FROM 1 TO n DO
str1:="Player "+STRING(k);
INPUT({{str2,[]}},str1,"Name: ");
players:=CONCAT(players,{str2});
END;

// Spin the wheel
RECT(RGB(255,255,0));
IF n==3 THEN
TEXTOUT_P("The goal is to get close to",
10,10,7);
TEXTOUT_P("\$1.00 without going over.",
10,40,7);
TEXTOUT_P("You can have up to two spins.",
10,70,7);
TEXTOUT_P("Good luck!",10,100,7);
ELSE
TEXTOUT_P("This is a spinoff.",10,10,7);
TEXTOUT_P("Highest number wins.",10,40,7);
END;
TEXTOUT_P("Press any key to
continue.",10,130,7);
WAIT(0);

// spinning the wheel
LOCAL t,w,w1,w2,ch; // pointer
t:=1;

FOR k FROM 1 TO n DO

MSGBOX(players(k)+"'s 1st spin");
m:=MAX(scores);

// Inital spin
w:=sbr1(t);
t:=w(1);
scores(k):=w(2);

// test for \$1 and bonus spin
IF scores(k)==100 THEN
RECT();
TEXTOUT_P(players(k)+" has \$1.00!",
10,10,7);
TEXTOUT_P("\$1,000 bonus!",10,40,7,
RGB(0,128,0));
bonuses(k):=1000;
WAIT(0);
// bonus spin
MSGBOX("Bonus Spin");
w:=sbr1(1);
t:=w(1); b:=0;
IF w(2)==5 OR w(2)==15 THEN b:=10000 END;
IF w(2)==100 THEN b:=25000 END;
IF b>0 THEN
str4:=players(k)+" has won \$"+
STRING(b)+"!";
bonuses(k):=bonuses(k)+b;
ELSE
str4:="No bonus money.";
END;
TEXTOUT_P(str4,10,180,7);
WAIT(0);
CONTINUE; END;

IF n==3 THEN
// second spin?
str4:=players(k)+" has "+
scores(k)+" cents.";
TEXTOUT_P(str4,10,180,7);
WAIT(0);

CHOOSE(ch,
"Score to beat: "+STRING(m)+
" Spin Again?",{"SPIN","STAY"});
IF ch==1 THEN

MSGBOX(players(k)+"'s 2nd spin");

w:=sbr1(t);
t:=w(1);
scores(k):=w(2)+scores(k);

// did the player go over?
IF scores(k)>100 THEN
str4:=players(k)+" has gone over.";
TEXTOUT_P(str4,10,200,7,RGB(255,0,0));
WAIT(0);
scores(k):=0;
END;

// test for \$1.00 and bonus spin
IF scores(k)==100 THEN
RECT();
TEXTOUT_P(players(k)+" has \$1.00!",
10,10,7);
TEXTOUT_P("\$1,000 bonus!",10,40,7,
RGB(0,128,0));
bonuses(k):=1000;
// bonus spin
MSGBOX("Bonus Spin");
w:=sbr1(1);
t:=w(1); b:=0;
IF w(2)==5 OR w(2)==15 THEN b:=10000 END;
IF w(2)==100 THEN b:=25000 END;
IF b>0 THEN
str4:=players(k)+" has won \$"+
STRING(b)+"!";
bonuses(k):=bonuses(k)+b;
ELSE
str4:="No bonus money.";
END;
TEXTOUT_P(str4,10,180,7);
WAIT(0);
CONTINUE;
END;

END;

END;

// total score
str4:=players(k)+" has "+
scores(k)+" cents.";
TEXTOUT_P(str4,10,180,7);
WAIT(0);

END;

// end of the game
RECT();
TEXTOUT_P("Final Scores",10,10,7);
FOR k FROM 1 TO n DO
TEXTOUT_P(players(k)+":",10,
10+25*k,7);
TEXTOUT_P(STRING(scores(k)/100,2,2),170,
10+25*k,7);
IF bonuses(k)>0 THEN
TEXTOUT_P("\$"+STRING(bonuses(k),2,0),
225,10+25*k,7,RGB(0,128,0)); END;
END;
WAIT(0);

END;

// subroutine spin the wheel
sbr1(x)
BEGIN
LOCAL wheel;

// colors
LOCAL b:=RGB(255,240,240); // snow white
LOCAL r:=RGB(255,0,0); // red
LOCAL dg:=RGB(0,255,0); // lime green
LOCAL tn:=RGB(255,208,0); // tangerine

// the wheel {{amount, color}}
wheel:=
{{100,r},{15,dg},{80,b},
{35,b},{60,b},{20,b},{40,b},
{75,b},{55,b},{95,b},{50,b},
{85,b},{30,b},{65,b},{10,b},
{45,b},{70,b},{25,b},{90,b},
{5,dg}};

// pointer
LOCAL pt,k,pm2,pm1,pc,pp1,pp2;
pt:=x;

// wheel display
FOR k FROM 1 TO RANDINT(20,60) DO
RECT();
pt:=pt MOD 20;

// display
pm2:=(pt+18) MOD 20;
pm1:=(pt+19) MOD 20;
pc:=pt MOD 20;
pp1:=(pt+1) MOD 20;
pp2:=(pt+2) MOD 20;

// box the numbers
RECT_P(74,44,164,144,0);
// borders
LINE_P(74,44,164,44,tn);
LINE_P(74,64,164,64,tn);
LINE_P(74,84,164,84,tn);
LINE_P(74,104,164,104,tn);
LINE_P(74,124,164,124,tn);
LINE_P(74,144,164,144,tn);
LINE_P(74,44,74,144,tn);
LINE_P(164,44,164,144,tn);
// side decoration - left with \$
FILLPOLY_P([(28,44),(43,24),(58,24),
(73,44),(73,144),(28,144)],
RGB(255,128,0));
TEXTOUT_P("\$",44,74,7,RGB(224,224,224));
// side decoration - right
FILLPOLY_P([(165,44),(180,24),(195,24),
(210,44),(210,144),(165,144)],
RGB(255,128,0));
// draw the pointer
TEXTOUT_P("<<",165,80,7,RGB(255,0,0));
// draw the numbers
TEXTOUT_P(wheel(pp2,1),95,40,7,
wheel(pp2,2));
TEXTOUT_P(wheel(pp1,1),95,60,7,
wheel(pp1,2));
TEXTOUT_P(wheel(pc,1),95,80,7,
wheel(pc,2));
TEXTOUT_P(wheel(pm1,1),95,100,7,
wheel(pm1,2));
TEXTOUT_P(wheel(pm2,1),95,120,7,
wheel(pm2,2));

// slow down the wheel
WAIT(0.08+0.01*k);
// next pointer
pt:=pt+1 MOD 20;

END;

// store results
LOCAL x1:=(pt-1) MOD 20;
IF x1==0 THEN x1:=20; END;
LOCAL x2:=wheel(x1,1);
RETURN {x1,x2};

END;

Source:

“Showcase Showdown” The Price Is Right Wiki.  Retrieved June 8, 2018.  http://priceisright.wikia.com/wiki/Showcase_Showdown

Eddie

All original content copyright, © 2011-2018.  Edward Shore.