Join us on Discord!
You can help CodeWalrus stay online by donating here.

Elemental Game: Guess/Deduct Number HP-Prime

Started by compsystems, January 02, 2015, 03:56:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

compsystems

Hello, sorry for my bad English  :-[

The following is a very simple game, the classic guess or deduce a number.

But there is a problem when deploying message in the terminal window, the last messages are not displayed, hopefully in future versions the development group of hpprime solve this problem


Code in Spanish  :-|
EXPORT AdivinarODeducir_Numero()
//test CAS Version: 1.1.2-11 and Operating System: version 6.2.9200
begin
     // Definición de Variables y tipo de contenedor
     local intentos := 0;
     local total_intentos := 0;
     local num_ingresado :=  0;
     local num_secreto := IP( random ( 1, 100 ) );
     
     print();
     print( "*** Ejecución Iniciada. ***" ); freeze;
     wait;
     
     // Presentación
     print( "Juego Matemático versión 0.8" );
     wait;
     print( "El programa genera un número real entre 1 y 100. Trate de deducirlo como recomendación en 8 intentos como máximo" );
     wait;
     
     // Entrada de Datos
     print( "Ingrese el # de intentos personalizados" );
     //freeze;
     wait( 1 );
     if NOT(input( total_intentos,"Total de Intentos","Intentos=","Digite un # como máximo total de intentos" ))
         then
         kill;
     end;
     wait;
     total_intentos := abs(total_intentos); // si el usuario ingresa números negativos se corrige
     print( "Intento #" + total_intentos);
     wait;
     intentos := total_intentos;
     
     print( "solo para hacer pruebas num aleatorio=" + num_secreto); // elimine esta sentencia para jugar verdaderamente
     wait;
     
     if NOT( input( num_ingresado,"Deducir_Numero","Num Ingresado=","Cual es el numero?" ) )
         then kill;
     end;
     print( ">"+num_ingresado );
     
     while( num_secreto <> num_ingresado and intentos > 1 ) do
         if num_secreto > num_ingresado then
             print( "El numero deducido es MENOR que el numero en cuestión" );
             wait;
             else
             print( "El numero deducido es MAYOR que el numero en cuestión" );
             wait;
         end;
         print("");
         
         intentos := intentos - 1; // decrementa en 1 el número de intentos
         print( "Le quedan "+intentos+" intento(s):" );
         print("Intento #" + intentos);
         //freeze;
         wait;
         if NOT( input( num_ingresado,"Deducir_Numero","Num Ingresado=","Cual es el numero?" ) ) then
             kill;
         end;
         print( ">"+num_ingresado );
     end;
     
     if num_secreto <> num_ingresado then
         print( "Perdió! trato en "+ ( ( total_intentos + 1 ) - intentos ) + " intento(s.) :~(, pero el numero era: "+ num_secreto);
         else
         print( "Gano! Usted lo dedujo en: "+ ( ( total_intentos + 1 ) - intentos ) +" intento(s.)" );
     end;
     print( "*** Ejecución Finalizada. ***" );
     
     //freeze;
     return "Done";
     
end;


Video showing the failure

New TI-edit for 68k_CPU calculators

http://home.arcor.de/p-engels/tiedit/

Dream of Omnimaga

Hi and welcome to the forums. :) Looks like HP will have some more bug fixing to do. X.x

Does scrolling fail on the real calculator too?
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Powered by EzPortal