Course of Game :
On starting the program the upper limit for the number to guess must be entered. The lower boundary is 1, the upper is the greatest representable integer (in this case the game lasts a little bit longer, of course . . . ;-) ).
If you are cheating you have to answer with "Y", when the HP-41CX is asking you "DO YOU CHEAT ?", otherwise you can say "N" here - if you don't make any errors ! Otherwise it's not possible for the HP-41CX to find the number ! ;-) Then the HP-41CX displays a number for a first try. In case the number to guess is greater you press the "G" key, or the "L" key in case it is lesser. If the number is the right one you have to press "R".
If you answered that you will cheat, you now have to enter the number, which must be guessed by the HP-41CX. In this case "guessing" and assessing will both be done by the HP-41CX. At the end the number of tries and the required time are displayed.
Program Listing :
First, in lines 4 through 12 three programmable key assignments are performed - old assignments to these keys are removed !
001 LBL "GAME4b" (4b, because in 4a the player has to guess) 002 " ZAHL RATEN" 003 AVIEW 004 "LE" 005 33 006 PASN 007 "GR" 008 22 009 PASN 010 "RI" 011 52 012 PASN 013 4 E-3 014 CLRGX 015 CF 29 016 CF 05 017 FIX 1 018 CLST 019 SETSW 020 "UPPER " 021 "BOUNDARY ?" 022 PROMPT 023 STO 00 024 CLA 025 89 026 AON 027 "DO YOU " 028 "CHEAT ?" 029 PROMPT 030 AOFF 031 ATOX 032 CLA 033 X=Y? 034 GTO 05 035 "NUMBER ?" 036 PROMPT 037 SF 27 038 LBL 07 039 XEQ 02 040 LBL 01 041 FIX 0 042 FS? 05 043 GTO 06 044 CLA 045 STOPSW 046 VIEW 01 047 STOP 048 LBL 02 049 RUNSW 050 RCL 00 051 2 052 / 053 INT 054 STO 01 055 STO 02 056 XEQ 03 057 RTN 058 LBL "LE" 059 RUNSW 060 3 061 RCL 02 062 X=Y? 063 GTO 11 064 RCL 02 065 RND 066 2 067 / 068 INT 069 RND 070 STO 02 071 E 072 RCL 02 073 X<=Y? 074 XEQ 04 075 LBL 12 076 RCL 02 077 ST- 01 078 XEQ 03 079 GTO 01 080 LBL "GR" 081 RUNSW 082 RCL 02 083 2 084 / 085 FIX 0 086 RND 087 STO 02 088 2 089 RCL 02 090 X=Y? 091 XEQ 04 092 RCL 02 093 ST+ 01 094 XEQ 03 095 GTO 01 096 LBL 03 097 ISG 03 098 "" (NOP) 099 RTN 100 LBL 04 101 E 102 STO 02 103 RTN 104 LBL 11 105 2 106 STO 02 107 GTO 12 108 LBL "RI" 109 "TRIES : " 110 ARCL 03 111 AVIEW 112 PSE 113 FIX 6 114 SF 29 115 "REQUIRED" 116 AVIEW 117 PSE 118 "TIME IN H.:" 119 AVIEW 120 PSE 121 RCLSW 122 VIEW X 123 CF 05 124 FIX 4 125 CLKEYS 126 GTO 13 127 LBL 05 128 SF 05 129 "NUMBER TO " 130 "GUESS:" 131 PROMPT 132 RUNSW 133 STO 04 134 "START GAME4b" 135 AVIEW 136 PSE 137 GTO 07 138 LBL 06 139 VIEW 01 140 PSE 141 RCL 01 142 RCL 04 143 X=Y? 144 GTO 08 145 X>Y? 146 GTO 09 147 GTO 10 148 LBL 08 149 STOPSW 150 TONE 8 151 "RIGHT" 152 AVIEW 153 GTO "RI" 154 LBL 09 155 "GREATER" 156 AVIEW 157 PSE 158 GTO "GR" 159 LBL 10 160 "LESSER" 161 AVIEW 162 PSE 163 GTO "LE" 164 LBL 13 165 CF 27 166 4 E-3 167 CLRGX 168 CLST 169 CLA 170 END
Back to HP-41CX Selected (Game) Programs
Back to Natural Sciences and Mathematical Games
Kai Schröder, 17.7.2003