Cyber Tennis Game for HP-41C - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-41C Software Library (/forum-11.html) +--- Thread: Cyber Tennis Game for HP-41C (/thread-8970.html) |
Cyber Tennis Game for HP-41C - Namir - 09-02-2017 08:01 PM The game assumes you are playing a 10-point match of cyber tennis. You play as many rounds until either you or the calculator wins 10 rounds. See instructions to play the game. Memory Map Code: R00 = random number HP-41C Listing Code: LBL "TENNIS" Games Instructions 1) Press [XEQ]"TENNIS or [shift][A] (in User Mode) to initialize the game. 2) The program stops to display current seed. You can alter this value or enter a new one. The new "seed" can be an integer, a fraction, or a number contains both. 3) Press [R/s]. The program determines who wins the current round: A) If the player wins, the program pauses and displays "YOU:" followed by current total wins for the player. B) If the calculator wins, the program pauses and displays "CALC:" followed by the current total wins for the calculator. C) If no one wins the current round, the program pauses and displays "TIE". 4) Repeat steps 2 and 3. If the player wins, the program displays "YOU WIN". If the calculator wins, the program displays "YOU LOSE". Note: You can set flag 00 to skip the "SEED?" prompt. RE: Cyber Tennis Game for HP-41C - Dieter - 09-03-2017 05:25 PM (09-02-2017 08:01 PM)Namir Wrote: Note: You can set flag 00 to skip the "SEED?" prompt. If this is the intended behaviour the FC? 00 test has to move down one step between "SEED?" and PROMPT. The comment at LBL 02 says that a negative number is displayed. That's not correct, all output is positive. LBL 01 generates a random integer between 0 and 99. This score is never displayed, so the routine can be completely removed and all calls replaced by XEQ E. This way also all references to R04 are obsolete. Since the probability of a tie then is near zero that part of the code can be removed as well. ;-) The program does not set the display mode. At least a FIX 0 and preferably also a CF 29 in the initialization routine is recommended. Dieter RE: Cyber Tennis Game for HP-41C - Namir - 09-05-2017 02:59 PM (09-03-2017 05:25 PM)Dieter Wrote:(09-02-2017 08:01 PM)Namir Wrote: Note: You can set flag 00 to skip the "SEED?" prompt. Edited listing's erroneous comments. RE: Cyber Tennis Game for HP-41C - Sylvain Cote - 09-05-2017 04:59 PM (09-05-2017 02:59 PM)Namir Wrote: Edited listing's erroneous comments. Hello Namir, What Dieter was trying to convey in his first remark, was this piece of code Code: RCL 00 should be modified to Code: RCL 00 Best regards, Sylvain RE: Cyber Tennis Game for HP-41C - Dieter - 09-05-2017 08:32 PM (09-05-2017 02:59 PM)Namir Wrote: Edited listing's erroneous comments. OK, but this does not change the way the program works, cf. Sylvain's explanation. Anyway... as you may know from earlier posts I'm a big fan of short and effective code, especially in programs for calculators with their limited ressources. Below is my attempt at a very streamlined version of "tennis". Maybe you can try it and see how you like it. It requires just R0...R2 and 43 steps. Code: 01 LBL"TENNIS" The flag 0 skip of the seed prompt has been omitted as I think that simply pressing [R/S] instead is even easier than setting a flag manually. Also a seed input is not required in every single round but only once when the program starts. Edit: updated listing to add comments and annotations Dieter RE: Cyber Tennis Game for HP-41C - Namir - 09-05-2017 11:41 PM (09-05-2017 04:59 PM)Sylvain Cote Wrote:(09-05-2017 02:59 PM)Namir Wrote: Edited listing's erroneous comments. Fixed the location of FC?00 command. RE: Cyber Tennis Game for HP-41C - Dieter - 09-06-2017 11:26 AM (09-05-2017 11:41 PM)Namir Wrote: Fixed the location of FC?00 command. Fine. But there still is one thing I do not understand: With flag 0 cleared program prompts for a seed in every single round of the match. Is there a special reason for this, or why don't you just put the seed prompt into the initialisation routine at LBL a so that it only appears when a new match is started – like in most other games programs? This also would make the whole flag 0 thing obsolete. Just curious, Dieter |