1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
{Premiers éléments d'un programme de jeu d'échecs}
{Compilateur : Turbo Pascal 7.0}
PROGRAM principes;
USES crt;
TYPE
TCoord = -1..10;
TPiece = -6..7;
TTableau12x12 = array [TCoord] of array [TCoord] of TPiece;
TTableau8x8 = array [0..7] of array [0..7] of TPiece;
TTableau4B = array [0..3] of Boolean;
TNomCaze = string [2];
TCoup = string [4];
VAR
Position : TTableau12x12;
x,y : TCoord;
trait : Boolean; {qui doit jouer}
passe : TCoord; {si un pion passe et, le cas échéant, sur quelle colonne}
autorisation1 : TTableau4B; {si le roque est permis (1/2)}
eschec : Boolean;
autorisation2 : TTableau4B; {si le roque est permis (2/2)}
compte : Byte; {nombre de coups échangés}
coup : TCoup; {"a8b8"}
CONST
Initiale : TTableau12x12=(
(007,007,007,007,007,007,007,007,007,007,007,007),
(007,007,007,007,007,007,007,007,007,007,007,007),
(007,007, 4 , 1 , 0 , 0 , 0 , 0 ,-1 ,-4 ,007,007),
(007,007, 2 , 1 , 0 , 0 , 0 , 0 ,-1 ,-2 ,007,007),
(007,007, 3 , 1 , 0 , 0 , 0 , 0 ,-1 ,-3 ,007,007),
(007,007, 5 , 1 , 0 , 0 , 0 , 0 ,-1 ,-5 ,007,007),
(007,007, 6 , 1 , 0 , 0 , 0 , 0 ,-1 ,-6 ,007,007),
(007,007, 3 , 1 , 0 , 0 , 0 , 0 ,-1 ,-3 ,007,007),
(007,007, 2 , 1 , 0 , 0 , 0 , 0 ,-1 ,-2 ,007,007),
(007,007, 4 , 1 , 0 , 0 , 0 , 0 ,-1 ,-4 ,007,007),
(007,007,007,007,007,007,007,007,007,007,007,007),
(007,007,007,007,007,007,007,007,007,007,007,007));
FUNCTION NomCaze (x,y : TCoord) : TNomCaze;
begin
NomCaze:=chr(x+96)+chr(y+48);
end;
BEGIN
textbackground(blue);
textcolor(white);
clrscr;
for x:=-1 to 10 do
begin
for y:=-1 to 10 do
begin
Position[x,y]:=Initiale[x,y];
{affichage pour vérification}
case Position[x,y] of
-6..-1 : textcolor(red);
0..6 : textcolor(white);
7 : textcolor(green);
end ;
gotoXY (x+3,12-y);
writeln (abs(Position[x,y]));
gotoXY (2*(x+3)+20,12-y);
writeln (NomCaze(x,y));
end;
end;
readln;
END. |
Partager