The Price Is Right Wheel Simulation - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: The Price Is Right Wheel Simulation (/thread-10925.html) The Price Is Right Wheel Simulation - Eddie W. Shore - 06-16-2018 07:49 PM How To Play This game simulates the Showcase Showdown round of the game show The Price Is Right. The wheel consists of amounts from 5 cents to 1 dollar in increments of 5 cents. The goal is to get closest to \$1.00 without going over. On the game show, the winner of the Showcase Showdown advances to the final Showcase round. 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. Code: ``` 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,[[2]]}},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;```