Autorisation : Membre
Nb de messages : 84
Inscrit le : Dim 15 Mai 2011, 11:33
Posté le : Sam 21 Mai 2011, 18:49
Voilà un (long) programme reprenant le concept du jeu Motus (les accros de la 2 penseront tout de suite à Thierry Beccaro )
Une fois programmé, vous verrez, ça colle avec les règles officielles du jeu, mis à part le timing (il n'y en a pas, la machine est déjà si lente à trouver les lettres) et le dictionnaire (désolé, je n'arrive pas à faire avaler le Larousse à ma machine à calculer)
Le programme:
Code
prgmMOTUS - MOTUS game (c) 2011 Corentin FERRY
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Disp "MOTUS VER 1.0.2"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Chaîne1
{41,42,43,51,52,53,54,55,61,62,63,64,65,71,72,73,74,75,81,82,83,84,85,91,92,93}->L1
EffListe L2
EffListe L3
{0}->L2
{0}->L4
{0}->L3
0->G
Disp "NB DE LETTRES?"
Input N
While N>13 ou N<5
Disp "ENTREZ UN NOMBRE"
Disp "ENTRE 5 ET 13"
Input N
End
partEnt(N)->N
EffEcr
CoordRect:CoordNAff:QuadNAff:AxesNAff:EtiqNAff:ExpNAff
0->Xmin
93->Xmax
0->Ymin
62->Ymax
EffDessin
Texte(1,1,"ENTREZ LE MOTUS A TROUVER...")
Texte(45,1,"EFFACER:TOUCHE ANNUL")
TEXTE(55,1,"QUITTER: TOUCHE MODE")
0->[theta]
While [theta]<(N+1)
codeTouche->C
If C=22:Then
Goto E
End
If [theta]<N ou C=45:Then
0->M
If C=45 et [theta]>1:Then
dim(L2)-1->dim(L2)
[theta]-1->[theta]
For(X,4[theta],4[theta]+4)
For(Y,7,12)
Pxl-Off(Y,X)
End
End
If [theta]=N-1:Then
For(Y,1,70)
For(X,35,40)
Pxl-Off(Y,X)
End
End
End
End
dim(L2)->D
For(V,1,26)
If L1(V)=C:Then
V->L2(dim(L2)+1)
Texte(7,4[theta],sous-Chaîne(Chaîne1,V,1))
End
End
End
If C=105 et [theta]=N:Then
[theta]+1->[theta]
End
If dim(L2)[!=]D:Then
[theta]+1->[theta]
End
If [theta]=N et M=0:Then
Texte(35,1,"ENTREE:VALIDER")
1->M
D+1->D
End
End
EffDessin
For(U,00,63,9)
Horizontale U
End
93/N->L
For(U,00,93,L)
Verticale U
End
L2(2)->L4(2)
For(A,3,N+1)
0->L4(A)
End
L2(5)->L4(5)
For([theta],0,6)
For(A,2,N+1)
If L4(A)[!=]0:Then
Texte(arrondi(9[theta]+1,0),arrondi(L*(A-2)+L/2-2,0),sous-Chaîne(Chaîne1,L4(A),1))
End
End
0->F
While F<N
codeTouche->C
If C[!=]0:Then
For(H,1,26)
If L1(H)=C:Then
Texte(arrondi(9[theta]+1,0),arrondi(LF+((L/2)-2),0),sous-Chaîne(Chaîne1,H,1))
H->L3(dim(L3)+1)
F+1->F
End
End
End
End
For(P,2,N+1)
If L2(P)=L3(P):Then
G+1->G
L3(P)->L4(P)
For(Y,L(P-2),L(P-1))
For(X,9[theta],9[theta]+8)
Pxl-Change(arrondi(X,0),arrondi(Y,0))
End
End
Else
0->J
For(I,1,N+1)
If L3(P)=L2(I) et J=0:Then
1->J
For(Y,L(P-2),L(P-1),2)
For(X,9[theta],9[theta]+8,2)
Pxl-Change(arrondi(X,0),arrondi(Y,0))
End
End
End
End
End
End
{0}->L3
If G=N:Then
0->G
Disp "VICTOIRE!"
Goto E
Else
0->G
End
End
[theta]-1->[theta]
For(R,0,N-1)
arrondi(9[theta]+1,0)->X
arrondi(LR+(L/2)-2,0)->Y
sous-Chaîne(Chaîne1,L2(R+2),1)->Chaîne2
Texte(X,Y,Chaîne2)
For(Y,LR,LR+L)
For(X,9[theta],9[theta]+8)
Pxl-Change(arrondi(X,0),arrondi(Y,0))
End
End
End
0->[theta]
While [theta]<500
[theta]+1->[theta]
End
EffDessin
Disp "DEFAITE!"
Lbl E
CoordRect:CoordAff:QuadNAff:AxesAff:EtiqNAff:ExpAff
ZStandard
Disp
Autorisation : Membre
Nb de messages : 1387
Inscrit le : Ven 25 Mar 2011, 22:58
Posté le : Dim 22 Mai 2011, 11:41
Je ne connais pas le jeux et j'ai la flemme de le recopier mais il peut être optimisé (ce qui l'accélaire (très) légèrement par la même occasion):
Code
prgmMOTUS - MOTUS game (c) 2011 Corentin FERRY
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Disp "MOTUS VER 1.0.2 //ici
"ABCDEFGHIJKLMNOPQRSTUVWXYZ->Chaîne1 //ici
{41,42,43,51,52,53,54,55,61,62,63,64,65,71,72,73,74,75,81,82,83,84,85,91,92,93->L1 //ici (supression du "}" )
EffListe L2
EffListe L3
{0->L2 //ici
{0->L4 //ici
{0->L3 //ici
EffVar G Input"NB DE LETTRES?" , N //ici
While N>13 ou N<5
Disp "ENTREZ UN NOMBRE //ici
Disp "ENTRE 5 ET 13 //ici
Input N
End
partEnt(N->N //ici
EffEcr
CoordRect:CoordNAff:QuadNAff:AxesNAff:EtiqNAff:ExpNAff
0->Xmin
93->Xmax
0->Ymin
62->Ymax
EffDessin
Texte(1,1,"ENTREZ LE MOTUS A TROUVER... //ici
Texte(45,1,"EFFACER:TOUCHE ANNUL //ici
TEXTE(55,1,"QUITTER: TOUCHE MODE //ici
EffVar [theta] While [theta]<(N+1 //ici
codeTouche->C
If C=22:Goto E //ici
If [theta]<N ou C=45:Then
0->M
If C=45 et [theta]>1:Then
dim(L2)-1->dim(L2 //ici
[theta]-1->[theta]
For(X,4[theta],4[theta]+4 //ici
For(Y,7,12 //ici
Pxl-Off(Y,X //ici
End
End
If [theta]=N-1:Then
For(Y,1,70 //ici
For(X,35,40 //ici
Pxl-Off(Y,X //ici
End
End
End
End
dim(L2->D //ici
For(V,1,26 //ici
If C=L1(V:Then //ici
V->L2(1+dim(L2 //ici
Texte(7,4[theta],sous-Chaîne(Chaîne1,V,1 //ici
End
End
End
If C=105 et [theta]=N:[theta]+1->[theta] //ici
If D[!=]dim(L2:[theta]+1->[theta] //ici
If [theta]=N et non(M:Then //ici
Texte(35,1,"ENTREE:VALIDER //ici
1->M
D+1->D
End
End
EffDessin
For(U,0,63,9 //ici
Horizontale U
End
93/N->L
For(U,00,93,L //ici
Verticale U
End
L2(2->L4(2 //ici
For(A,3,N+1 //ici
0->L4(A //ici
End
L2(5->L4(5 //ici
For([theta],0,6 //ici
For(A,2,N+1 //ici
If L4(A:Texte(arrondi(9[theta]+1,0),arrondi(L*(A-2)+L/2-2,0),sous-Chaîne(Chaîne1,L4(A),1 //ici
End
EffVar FWhile F<N //ici
codeTouche->C
If C:Then //ici
For(H,1,26 //ici
If C=L1(H:Then //ici
Texte(arrondi(9[theta]+1,0),arrondi(LF+((L/2)-2),0),sous-Chaîne(Chaîne1,H,1 //ici
H->L3(1+dim(L3 //ici
F+1->F
End
End
End
End
For(P,2,N+1 //ici
If L2(P)=L3(P:Then //ici
G+1->G
L3(P->L4(P //ici
For(Y,L(P-2),L(P-1 //ici
For(X,9[theta],9[theta]+8 //ici
Pxl-Change(arrondi(X,0),arrondi(Y,0 //ici
End
End
Else
0->J
For(I,1,N+1 //ici
If L3(P)=L2(I) et non(J:Then //ici
1->J
For(Y,L(P-2),L(P-1),2 //ici
For(X,9[theta],9[theta]+8,2 //ici
Pxl-Change(arrondi(X,0),arrondi(Y,0 //ici
End
End
End
End
End
End
{0->L3 //ici
If G=N:Then
EffVar GDisp "VICTOIRE! //ici
Goto E
Else
0->G
End
End
[theta]-1->[theta]
For(R,0,N-1 //ici
arrondi(9[theta]+1,0->X //ici
arrondi(LR+(L/2)-2,0->Y //ici
sous-Chaîne(Chaîne1,L2(R+2),1->Chaîne2 //ici
Texte(X,Y,Chaîne2 //ici
For(Y,LR,LR+L //ici
For(X,9[theta],9[theta]+8 //ici
Pxl-Change(arrondi(X,0),arrondi(Y,0 //ici
End
End
End
EffVar [theta] While [theta]<500 //ici
[theta]+1->[theta]
End
EffDessin
Disp "DEFAITE! //ici
Lbl E
CoordRect:CoordAff:QuadNAff:AxesAff:EtiqNAff:ExpAff
ZStandard
Disp
---------------------- mort à l'inutile, place à la mémoire libre et aux programmes
Autorisation : Membre
Nb de messages : 84
Inscrit le : Dim 15 Mai 2011, 11:33
Posté le : Dim 22 Mai 2011, 11:54
Si tu veux À la base, je code en C/C++/PHP/JS, tous ces langages qui nécessitent la fermeture des parenthèses, des guillemets etc, je vais essayer ta modif et te dire le delta en terme de rapidité
Merci en tout cas de l'optimisation;) N'ayant pas le câble Ti Graph Link ni de port COM sur ma machine (peut être un jumper, mais j'ai acheté la mobo cette année donc je doute), je recopie tout à la main!
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 84
Inscrit le : Dim 15 Mai 2011, 11:33
Posté le : Dim 22 Mai 2011, 16:21
J'ai du laisser l'arondissement de théta en éditant mon programme; à la base, dans la version 1.00 théta n'était pas entier puisque il était diviseur de la hauteur de l'écran. Maintenant que je la définis au début du programme, l'arondissement n'est plus utile mais j'ai oublié de le supprimer.
Concernant les parenthèses, je me répète, je débarque du C/C++/PHP ou il faut mettre des ; en fin de ligne et fermer toutes les parenthèses et guillemets, donc j'ai un peu la syntaxe forgée en tête
Effectivement, pour les usagers intensifs de la mémoire il faut optimiser les programmes; n'ayant jamais trop de programmes sur ma machine je ne me suis jamais posé la question de l'optimisation du code
Autorisation : Membre
Nb de messages : 1387
Inscrit le : Ven 25 Mar 2011, 22:58
Posté le : Lun 23 Mai 2011, 9:48
En tout cas, si tu n'a pas le cable ordi-TI , je te conseille de commencer à optimiser rapidement car sinon le jour ou en classe on te demande de faire un petit programme et que tu n'a plus de place, tu n'a pas le temps d'optimiser et tu doit supprimer tes programmes qui t'ont pris tant de temps.
Sandro
---------------------- mort à l'inutile, place à la mémoire libre et aux programmes
Autorisation : Membre
Nb de messages : 3767
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Lun 23 Mai 2011, 22:17
Veinard, moi je n'ai eu que trois cours de prog en classe (et c'était même trop tard, j'avais appris ici)
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 3767
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Lun 23 Mai 2011, 22:56
Est-ce un nouveau bug ou le classique des noms longs sur calcu française ?
Joue avec les contrastes avant d'appuyer sur entrer afin de voir ce que fait la calculatrice pendant le recopiage.
PS : Tu t'es surpassé pour faire ce HS. Je suis encore vaincu.
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 84
Inscrit le : Dim 15 Mai 2011, 11:33
Posté le : Mar 24 Mai 2011, 13:57
Citer : linkakro
Veinard, moi je n'ai eu que trois cours de prog en classe (et c'était même trop tard, j'avais appris ici)
J'ai jamais programmé en classe sauf cette année, de tout petits algorithmes... Le premier gros programme que j'aie fait fut DETFX, pour déterminer et démontrer l'équation d'une fonction affine... Mais je l'ai perdu!
@Akmdad: J'ai le même souci, dès que je rappelle un programme, ça maerde, mais je presse sur Entrée, puis j'éteins et je rallume la machine jusqu'à ce qu'elle m'affiche l'écran principal (elle n'affiche rien mais travaille toujours en fait )
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)