Les regles sont celles du puissance 4 : le but est d’aligner horizontalement,verticalement, ou en diagonale 4 pions. Le jeu s’arrête alors.

Version PostScript / Version PDF

**Attention : Ces programmes doivent toujours être écrits en mode Wrt/Matrix.**

La matrice est indispensable.. La matrice doit être definie ainsi : Mat W[1,9] ## Programme Puissance-4: Alias Prog J : 256 pas.

PUISSANCE-4

"PUISSANCE 4"
"               PAR REMI P." Disp
" "
Lbl 1
"     - PUISSANCE 4 -"
" "
" 1 - COMMENCER"
" 2 - CONTINUER"
" 3 - REPRENDRE"
" 0 - QUITTER"
"CHOIX"?->A
A=1=>Goto A
A=2=>Goto B
A=3=>Goto C
A=0=>Goto Z
Goto 1
Lbl A:9->B:Lbl 2:0->Mat W[1,B]:Dsz B:Goto  2
Mcl:1->L:Prog K
Lbl B:Prog L:Goto 1
Lbl C:Prog K:Prog L:Goto 1
Lbl Z:4->A
"OK"

Programme Puis-Graph : Alias Prog K : 283 pas.

PUIS-GRAPH

Cls
Range 1,127,0,1,63,0
9->A:Lbl 1
Plot A*14, 1 : Plot A*14,56: Line
A*14+5->X:6->Y:A->W
A 9=>Prog r
Dsz A : Goto 1
7->A:Lbl 2
Plot 1,A*8:Plot 126,A*8:Line
A*8++6->Y:5->X:11->W
A7=>Prog r
Dsz A: Goto 2
8->D: Lbl 3
Mat W[1,D]->F
1->E
F=0=>Goto 5
Int Log F+1 ->E
Lbl 4
Abs (Int (F/10^(E-1))-Int (F/10^E)*10->G
G1=>G2=>Goto 5
G-1->C
D*14+4->X:E*8+1->Y:Prog 6
Lbl 5
Dsz E:Goto 4
Dsz D : Goto 3

Programme Puis-Run :Alias Prog L : 332 pas

PUIS-RUN

Int (Mat W[1,9]/100)+1->L
Frac (Mat W[1,9]/100)*100->K
Lbl A
60->Y:70->X
Plot X,Y Disp
XGoto A
X>=126 =>Goto A
Int (X/14) ->M:Mat W[1,M]->N:0->O
N0=>Int log N+1->O
O6=>Goto A
L*10^O+N->Mat W[1,M]:L-1->C
(O+1)*8+1->Y:M*14+3->X:Prog 6
M->A:O+1->B:Prog M:Z=L=>Goto C
K+1->K:K>=6*8=>Goto B
L+1->L:L=3=>1->L
(L-1)*100+K->Mat W[1,9]
Goto A
Lbl B:"MATCH NUL." Disp:Goto Z
Lbl C
L=1=>"VICTOIRE DES BLANCS." Disp
L=2=>"VICTOIRE DES NOIRS." Disp
Goto Z
Lbl Z

Programme Puis-Test :Alias Prog M : 239 pas

PUIS-TEST
0->Z:1->P~T:0->Q~R:-1->U~W
4->E:Lbl 1
1->G:2->F:Lbl 2
-N[E*2]->N[E*2]:-N[E*2+1]->N[E*2+1]
A->C:B->D:Lbl 3
N[E*2]+C->C: N[E*2+1]+D->D
C>0=>D>0=>CDGoto 5:Goto 4
Lbl 5
Abs (Int (Mat W[1,C]/10^(D-1))-Int (Mat W[1,C]/10^D) *10) ->H: H  L=>Goto 4
G+1->G
G=4=>L->Z: Z=L=>Goto Z:Goto 3
Lbl 4
Dsz F: Goto 2
Dsz E : Goto 1
Lbl Z

© Copyright 1995 – Rémi Peyronnet