Code:
const motifs: array[0..13, 0..1]of string = (
('OOOO', 'XXXX'),
('OOO.', 'XXX.'),
('.OOO', '.XXX'),
('OO.O', 'XX.X'),
('O.OO', 'X.XX'),
('OO..', 'XX..'),
('O.O.', 'X.X.'),
('O..O', 'X..X'),
('.O.O', '.X.X'),
('..OO', '..XX'),
('O...', 'X...'),
('.O..', '.X..'),
('..O.', '..X.'),
('...O', '...X')
);
const
demiDroites: array[0..24, 0..3] of integer = (
(1, 1, +1, 0),
(1, 2, +1, 0),
(1, 3, +1, 0),
(1, 4, +1, 0),
(1, 5, +1, 0),
(1, 6, +1, 0),
(1, 1, 0, +1),
(2, 1, 0, +1),
(3, 1, 0, +1),
(4, 1, 0, +1),
(5, 1, 0, +1),
(6, 1, 0, +1),
(7, 1, 0, +1),
(1, 1, +1, +1),
(1, 2, +1, +1),
(1, 3, +1, +1),
(1, 4, +1, -1),
(1, 5, +1, -1),
(1, 6, +1, -1),
(7, 1, -1, +1),
(7, 2, -1, +1),
(7, 3, -1, +1),
(7, 4, -1, -1),
(7, 5, -1, -1),
(7, 6, -1, -1)
);
function tClasseGrille.Points(const aPion: char): integer;
var
i, j, k, l: integer;
x, y: integer;
segment: string;
begin
result := 0;
l := Ord(aPion = BLANC);
for i := Low(demiDroites) to High(demiDroites) do
begin
x := demiDroites[i, 0];
y := demiDroites[i, 1];
segment := ' ';
j := 1;
repeat
segment[j] := grille[x, y];
Inc(x, demiDroites[i, 2]);
Inc(y, demiDroites[i, 3]);
Inc(j);
until (x < UN) or (x > SEPT) or (y < UN) or (y > SIX);
for j := Low(motifs) to High(motifs) do
if Pos(motifs[j, l], segment) > 0 then
begin
case j of
0:
k := 75000;
1..4:
k := 2500;
5..9:
k := 50;
else
k := 1;
end;
Inc(result, k);
end;
end;
end;
Bookmarks