Page 1 of 1

Trouve le nombre amélio et opti

Unread postPosted: 28 Sep 2015, 22:26
by Commando12345
voilà un petit jeu pour 83 PCE programmé on calc j'aimera avoir votre avis et de l'aide pour l'opti :D (et comment l'ameliorer)

Code: Select all
Lbl X
EffÉcran
DelVar PDelVar YDelVar ZDelVar SDelVar MDelVar ADelVar T
14→X
5000→V
Menu("TROUVE LE NOMBRE","NORMAL(0-5000)",1,"VIES LIMITEES",2,"PERSONALISE",3,"QUITTER",θ
Lbl 3
2→T
Disp "NOMBRE MAXIMUM?"
Input "",V
Menu("VIES","VIES ILLIMITEES",1,"VIES PERSO",B
Lbl 2
1→T
Lbl B
EffÉcran
Disp "NOMBRE DE VIES
Input "",X
X→A
Lbl 1
nbrAléatEnt(0,V→Z
EffÉcran
Disp "QUEL EST LE NOMBRE?
Input "",Y
While Y≠Z
If Y<Z
Disp "TROP PETIT!
If Y>Z
Disp "TROP GRAND!
S+1→S
If S=A et (Y>Z  ou Y<Z)
Then
EffÉcran
Output(5,9,"GAME OVER
1→P
Goto A
End
Input "",Y
End
If Y=Z
Then
EffÉcran
Output(4,7,"TU AS GAGNE EN
Output(5,10,S+1
Output(5,13,"COUPS
End
Lbl A
If S≥⌊NMBR(1) et non(T
Then
Output(7,7,"HIGH SCORE:
Output(7,19,⌊NMBR(1
Goto Z
End
If S<⌊NMBR(1) et non(T
Then
Output(7,6,"NOUVEAU RECORD:
S+1→⌊NMBR(1
Output(7,21,⌊NMBR(1
Goto Z
End
If S≥⌊NMBR(2) ou P=1 et T=1
Then
Output(7,7,"RECORD:
Output(7,19,⌊NMBR(2
Goto Z
End
If S<⌊NMBR(2) et T=1 et non(P
Then
Output(7,6,"NOUVEAU RECORD:
S+1→⌊NMBR(2
Output(7,21,⌊NMBR(2
Goto Z
End
If S≥⌊NMBR(3) ou P=1 et T=2
Then
Output(7,7,"RECORD:
Output(7,19,⌊NMBR(3
Goto Z
End
If S<⌊NMBR(3) et T=2 et non(P
Then
Output(7,6,"NOUVEAU RECORD:
S+1→⌊NMBR(3
Output(7,21,⌊NMBR(3
End
Lbl Z
Pause
Goto X
Lbl θ
EffÉcran
Fin

*petit édit

Re: Trouve le nombre amélio et opti

Unread postPosted: 28 Sep 2015, 22:32
by noelnadal
Remplace les 0->V par des Delvar V
Ne ferme pas les guillemets à la fin des Disp.
Remplace T=0 par non(T sans la parenthèse à la fin.
idem pour nbrAléatEnt(0,V)→Z à remplace par nbrAléatEnt(0,V→Z

Après, les Goto/Lbl, j'aime moyennement, mais bon...

Re: Trouve le nombre amélio et opti

Unread postPosted: 29 Sep 2015, 10:51
by Hamza.S
Code: Select all
Menu("VIES","VIES ILLIMITEES",1,"VIES PERSO",B
Lbl B
EffÉcran
Disp "NOMBRE DE VIES" // utilisé un peu plus bas
Input "",X  // idem
Goto S  // inutile
Lbl 2
1→T
Disp "NOMBRE DE VIES
Input "",X
Lbl S  // inutile sauf si un autre Goto l'utilise
// j'ai pas lu tout le code pour le moment

tu répètes la même chose presque inutilement, pour l'améliorer tu peux faire
Code: Select all
Menu("VIES","VIES ILLIMITEES",1,"VIES PERSO",B
Lbl 2
1→T
Lbl B
EffÉcran
Disp "NOMBRE DE VIES
Input "",X


une question : classes-tu le score en fonction du nombre de coups?

Re: Trouve le nombre amélio et opti

Unread postPosted: 29 Sep 2015, 11:50
by Hamza.S
pensez-vous que cette boucle peut remplacer le début du boucle While?
je l'ai fait sans réfléchir
Code: Select all
Lbl 1
randInt(0,V→Z
ClrHome
For (I,1,A)
Disp "QUEL EST LE NOMBRE?
Input "",Y
S+1→S
If Y<Z
Disp "TROP PETIT!
If Y>Z
Disp "TROP GRAND!
If Y=Z
Then
EffÉcran
Output(4,7,"TU AS GAGNE EN
Output(5,10,S
Output(5,13,"COUPS
End
If S=A and (Y>Z or Y>Z)
Then
Output(5,9,"GAME OVER
1→P
End
...
End

Re: Trouve le nombre amélio et opti

Unread postPosted: 29 Sep 2015, 12:04
by GalacticPirate
Bon, j'ai fait de l'opti : fusion des Lbl 2 et Lbl B, et par conséquent suppression du Lbl S qui ne servait donc plus à rien. J'ai aussi viré le dernier Goto Z inutile. Bref, aux codeurs, dites moi ce que vous en pensez :
Code: Select all
Lbl X
EffÉcran
DelVar PDelVar YDelVar ZDelVar SDelVar MDelVar ADelVar T
14→X
"BLA→Str1
5000→V
Menu("TROUVE LE NOMBRE","NORMAL(0-5000)",1,"VIES LIMITEES",2,"PERSONALISE",3,"QUITTER",θ
Lbl 3
2→T
Disp "NOMBRE MAXIMUM?"
Input "",V
Menu("VIES","VIES ILLIMITEES",1,"VIES PERSO",B
Lbl 2
1→T
Lbl B
EffÉcran
Disp "NOMBRE DE VIES
Input "",X
X→A
Lbl 1
nbrAléatEnt(0,V→Z
EffÉcran
Disp "QUEL EST LE NOMBRE?
Input "",Y
While Y≠Z
If Y<Z
Disp "TROP PETIT!
If Y>Z
Disp "TROP GRAND!
S+1→S
If S=A
Then
EffÉcran
Output(5,9,"GAME OVER
1→P
Goto A
End
Input "",Y
End
If Y=Z
Then
EffÉcran
Output(4,7,"TU AS GAGNE EN
Output(5,10,S+1
Output(5,13,"COUPS
End
Lbl A
If S≥⌊NMBR(1) et non(T
Then
Output(7,7,"HIGH SCORE:
Output(7,19,⌊NMBR(1
Goto Z
End
If S<⌊NMBR(1) et non(T
Then
Output(7,6,"NEW HIGH SCORE:
S+1→⌊NMBR(1
Output(7,21,⌊NMBR(1
Goto Z
End
If S≥⌊NMBR(2) ou P=1 et T=1
Then
Output(7,7,"HIGH SCORE:
Output(7,19,⌊NMBR(2
Goto Z
End
If S<⌊NMBR(2) et T=1 et non(P
Then
Output(7,6,"NEW HIGH SCORE:
S+1→⌊NMBR(2
Output(7,21,⌊NMBR(2
Goto Z
End
If S≥⌊NMBR(3) ou P=1 et T=2
Then
Output(7,7,"HIGH SCORE:
Output(7,19,⌊NMBR(3
Goto Z
End
If S<⌊NMBR(3) et T=2 et non(P
Then
Output(7,6,"NEW HIGH SCORE:
S+1→⌊NMBR(3
Output(7,21,⌊NMBR(3
End
Lbl Z
Pause
Goto X
Lbl θ
EffÉcran
Fin

Re: Trouve le nombre amélio et opti

Unread postPosted: 29 Sep 2015, 12:38
by noelnadal
Tu peux remplaçer "HIGH SCORE" par "RECORD", ça te fait gagner des octets. :P

Re: Trouve le nombre amélio et opti

Unread postPosted: 29 Sep 2015, 12:47
by Ti64CLi++
Et remplacer TROP GROS par - et TROP PETIT par + :troll:

Re: Trouve le nombre amélio et opti

Unread postPosted: 29 Sep 2015, 13:42
by noelnadal
Non mais, vive le français, quoi... :P

Re: Trouve le nombre amélio et opti

Unread postPosted: 30 Sep 2015, 17:22
by Commando12345
Je l'ai opti (édit du 1er post) encore quelque chose à faire ?