Sunday, June 3, 2018

HP Prime: Treasure Hunt


HP Prime:  Treasure Hunt

Background

The game show Treasure Hunt had three series on TV:  1956 – 1959, 1973 – 1977, and 1981 – 1982.  Generally, two contestants (three in the 1973 – 1977 series) play a mini-game where the winner earned the right to hunt for treasure. 

On the treasure hunt, the contestant selected from 1 of 30 (66 in 1981 – 1982) boxes.  Each box had a cash envelope that was offered as a sure thing.  Either the contestant took the sure thing or took the box.  The boxes contained various prizes, from cars and trips to “klunks” (prank prizes not worth very much).  One box always had a cash jackpot.  In the 1973 – 1977 series, the jackpot box had $25,000.

In the 1973 -1977 and 1981 – 1982 series, the contestants were always female.

Can you find the treasure?

The program GAME_TREASURE presents you with 12 boxes, one has $50,000.  Select a box by just tapping the screen.  You will then be presented with a sure thing.  A choose box will be presented where you make your choice to take the sure thing or take a risk and open the box.  Good luck.  Below is an example game in progress.





HP Prime Program GAME_TREASURE

EXPORT GAME_TREASURE()
BEGIN
// EWS 2018-04-14

// Intro screen
// Dark green screen (fir green)
RECT(#003000h);

// Intro screen
TEXTOUT_P("Are you ready to make money?",
0,0,4,#FFFF00h);
TEXTOUT_P("Welcome to your treasure",
0,20,4,#FFFF00h);
TEXTOUT_P("hunt! Choose your box and",
0,40,4,#FFFF00h);
TEXTOUT_P("GOOD LUCK!",
0,60,4,#FFFF00h);
WAIT(1.5);

// select money boxes
LOCAL tlst,sure,tar;
tlst:=RANDINT(12,1,15000);
tar:=RANDINT(1,12);
tlst(tar):=50000;
sure:=RANDINT(1000,6000);

// draw boxes
LOCAL tx,ty,I,J,L:=1;
tx:={10,70,80,140,150,210,220,280};
ty:={10,60,70,120,130,180};

LOCAL c,m,m1,mx,my;

WHILE MOUSE(1)≥0 DO END;

// draw the boxes
RECT();
FOR J FROM 0 TO 2 DO
FOR I FROM 0 TO 3 DO

FILLPOLY_P({
(tx(2*I+1),ty(2*J+1)),
(tx(2*I+2),ty(2*J+1)),
(tx(2*I+2),ty(2*J+2)),
(tx(2*I+1),ty(2*J+2))},#0000FFh);
// text
TEXTOUT_P(L,tx(2*I+1)+10,
ty(2*J+1)+15,7,#FFFFFFh);
L:=1+L;
END;
END;

// get user choice
REPEAT
m:=MOUSE(); m1:=m(1);
UNTIL SIZE(m1)>0;
mx:=m1(1); my:=m1(2);

IF (mx≥10 AND mx≤70) AND
(my≥10 AND my≤60) THEN
c:=1;
END;

IF (mx≥80 AND mx≤140) AND
(my≥10 AND my≤60) THEN
c:=2;
END;

IF (mx≥150 AND mx≤210) AND
(my≥10 AND my≤60) THEN
c:=3;
END;

IF (mx≥220 AND mx≤280) AND
(my≥10 AND my≤60) THEN
c:=4;
END;

IF (mx≥10 AND mx≤70) AND
(my≥70 AND my≤120) THEN
c:=5;
END;

IF (mx≥80 AND mx≤140) AND
(my≥70 AND my≤120) THEN
c:=6;
END;

IF (mx≥150 AND mx≤210) AND
(my≥70 AND my≤120) THEN
c:=7;
END;

IF (mx≥220 AND mx≤280) AND
(my≥70 AND my≤120) THEN
c:=8;
END;

IF (mx≥10 AND mx≤70) AND
(my≥130 AND my≤180) THEN
c:=9;
END;

IF (mx≥80 AND mx≤140) AND
(my≥130 AND my≤180) THEN
c:=10;
END;

IF (mx≥150 AND mx≤210) AND
(my≥130 AND my≤180) THEN
c:=11;
END;

IF (mx≥220 AND mx≤280) AND
(my≥130 AND my≤180) THEN
c:=12;
END;

// analysis
RECT();
TEXTOUT_P("BOX "+c,10,10,6);
TEXTOUT_P("Today's sure thing is $"+
sure,10,30,6,#0000FFh);
WAIT(2.5);
LOCAL h;
CHOOSE(h,"$"+sure+"?",
"Take it!","The box!");

RECT();
TEXTOUT_P("BOX "+c,10,10,6);
IF h==1 THEN
TEXTOUT_P("Today's sure thing is $"+
sure,10,30,6,#0000FFh);
TEXTOUT_P("Your box had $"+
tlst(c),10,50,6);
ELSE
TEXTOUT_P("You turned down $"+sure,
10,30,6);
WAIT(0.75);
TEXTOUT_P("Your box has.... ",
10,50,6);
WAIT(0.75);
TEXTOUT_P("$"+tlst(c)+"!",
10,70,6,#00A060h);
END;

IF tlst(c)≠50000 THEN
LOCAL w;
w:=POS(tlst,50000);
TEXTOUT_P("Box "+w+" had the $50000.",
10,110,6);
END;

WAIT(0);
END;

Source:
“Treasure Hunt (U.S. Game Show)” Wikipedia.  April 12, 2018.  Retrieved June 3, 2018.  Link:  https://en.wikipedia.org/wiki/Treasure_Hunt_(U.S._game_show)

Eddie

All original content copyright, © 2011-2018.  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.  Please contact the author if you have questions.

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

  Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...