📄 ueval.pas
字号:
unit Ueval;
interface
type
_avichain = record
value: integer;
x: integer;
y: integer;
end;
function addvalue: integer;
function countvalue: real;
function getmax: real;
implementation
uses
Sysutils, main, all;
var
point: integer;
function getmax: real;
var
//pus:array[1..9,1..9]of integer;
savcost: array[1..9, 1..9] of integer;
value2, a, b, s: real;
i, j, k: integer;
flag: boolean;
savaddflag: integer;
savcolor, savl, savr, savu, savd, savlu, savld, savru, savrd: integer;
cango: array[1..30] of _avichain;
temp: _avichain;
chesscount: integer;
procedure getmax2;
var
m, n: integer;
begin
if ((deepmax - depth) mod 2 = 0) then
changechess(cango[i].x, cango[i].y, compcolor, 0)
else
changechess(cango[i].x, cango[i].y, mancolor, 0);
if (chessable = 0) then
exit;
if last <> 1 then
begin
savaddflag := addflag;
savcolor := 0; savl := 0; savr := 0; savu := 0; savd := 0;
savlu := 0; savld := 0; savru := 0; savrd := 0;
for m := 1 to 8 do
for n := 1 to 8 do
begin
//pus[m,n]:=ichess[m,n];
savcost[m, n] := cost[m, n];
end;
end;
//else
//for m:=1 to 8 do
//for n:=1 to 8 do
//begin
//pus[m,n]:=ichess[m,n];
//end;
if ((deepmax - depth) mod 2 = 0) then
begin
changechess(cango[i].x, cango[i].y, compcolor, 2);
ichess[cango[i].x, cango[i].y] := compcolor;
savcolor := compcolor;
savl := l; savr := r; savu := u; savd := d;
savlu := lu; savld := ld; savru := ru; savrd := rd;
if last <> 1 then
begin
if runsteps < 2 then
begin
if ((cango[i].x = 1) and (cango[i].y = 2)) or ((cango[i].x = 1) and (cango[i].y = 7)) or ((cango[i].x = 8) and (cango[i].y = 2)) or ((cango[i].x = 8) and (cango[i].y = 7)) or ((cango[i].y = 1) and (cango[i].x = 2)) or ((cango[i].y = 1) and (cango[i].x = 7)) or ((cango[i].y = 8) and (cango[i].x = 2)) or ((cango[i].y = 8) and (cango[i].x = 7)) then
addflag := 1
else if ((cango[i].x = 2) and (cango[i].y = 2)) or ((cango[i].x = 7) and (cango[i].y = 7)) or ((cango[i].x = 7) and (cango[i].y = 2)) or ((cango[i].x = 2) and (cango[i].y = 7)) then
addflag := 1
else if ((cango[i].x = 1) and (cango[i].y = 1)) or ((cango[i].x = 8) and (cango[i].y = 8)) or ((cango[i].x = 8) and (cango[i].y = 1)) or ((cango[i].x = 1) and (cango[i].y = 8)) then
addflag := 1;
if level = 1 then
if (cango[i].x = 1) or (cango[i].x = 8) or (cango[i].y = 1) or (cango[i].y = 8) then addflag := 1;
end;
end;
end
else
begin
changechess(cango[i].x, cango[i].y, mancolor, 2);
ichess[cango[i].x, cango[i].y] := mancolor;
savcolor := mancolor;
savl := l; savr := r; savu := u; savd := d;
savlu := lu; savld := ld; savru := ru; savrd := rd;
if last <> 1 then
begin
if runsteps < 2 then
begin
if ((cango[i].x = 1) and (cango[i].y = 2)) or ((cango[i].x = 1) and (cango[i].y = 7)) or ((cango[i].x = 8) and (cango[i].y = 2)) or ((cango[i].x = 8) and (cango[i].y = 7)) or ((cango[i].y = 1) and (cango[i].x = 2)) or ((cango[i].y = 1) and (cango[i].x = 7)) or ((cango[i].y = 8) and (cango[i].x = 2)) or ((cango[i].y = 8) and (cango[i].x = 7)) then
addflag := 1
else if ((cango[i].x = 2) and (cango[i].y = 2)) or ((cango[i].x = 7) and (cango[i].y = 7)) or ((cango[i].x = 7) and (cango[i].y = 2)) or ((cango[i].x = 2) and (cango[i].y = 7)) then
addflag := 1
else if ((cango[i].x = 1) and (cango[i].y = 1)) or ((cango[i].x = 8) and (cango[i].y = 8)) or ((cango[i].x = 8) and (cango[i].y = 1)) or ((cango[i].x = 1) and (cango[i].y = 8)) then
addflag := 1;
end;
end;
end;
dec(runsteps);
dec(depth);
inc(steps);
can := 1;
s := getmax();
can := 1;
dec(steps);
inc(runsteps);
inc(depth);
if (cut = 1) then
begin
//addleft:=savaddl;
//addright:=savaddr;
//addtop:=savaddu;
//addbot:=savaddd;
for m := 1 to 8 do
for n := 1 to 8 do
begin
//pus[m,n]:=ichess[m,n];
savcost[m, n] := cost[m, n];
end;
if savcolor = compcolor then
begin
ichess[cango[i].x, cango[i].y] := none;
if savl <> 0 then for m := 1 to savl do ichess[cango[i].x - m, cango[i].y] := mancolor;
if savr <> 0 then for m := 1 to savr do ichess[cango[i].x + m, cango[i].y] := mancolor;
if savu <> 0 then for m := 1 to savu do ichess[cango[i].x, cango[i].y - m] := mancolor;
if savd <> 0 then for m := 1 to savd do ichess[cango[i].x, cango[i].y + m] := mancolor;
if savlu <> 0 then for m := 1 to savlu do ichess[cango[i].x - m, cango[i].y - m] := mancolor;
if savld <> 0 then for m := 1 to savld do ichess[cango[i].x - m, cango[i].y + m] := mancolor;
if savru <> 0 then for m := 1 to savru do ichess[cango[i].x + m, cango[i].y - m] := mancolor;
if savrd <> 0 then for m := 1 to savrd do ichess[cango[i].x + m, cango[i].y + m] := mancolor;
end
else
begin
ichess[cango[i].x, cango[i].y] := none;
if savl <> 0 then for m := 1 to savl do ichess[cango[i].x - m, cango[i].y] := compcolor;
if savr <> 0 then for m := 1 to savr do ichess[cango[i].x + m, cango[i].y] := compcolor;
if savu <> 0 then for m := 1 to savu do ichess[cango[i].x, cango[i].y - m] := compcolor;
if savd <> 0 then for m := 1 to savd do ichess[cango[i].x, cango[i].y + m] := compcolor;
if savlu <> 0 then for m := 1 to savlu do ichess[cango[i].x - m, cango[i].y - m] := compcolor;
if savld <> 0 then for m := 1 to savld do ichess[cango[i].x - m, cango[i].y + m] := compcolor;
if savru <> 0 then for m := 1 to savru do ichess[cango[i].x + m, cango[i].y - m] := compcolor;
if savrd <> 0 then for m := 1 to savrd do ichess[cango[i].x + m, cango[i].y + m] := compcolor;
end;
flag := true;
exit;
end;
if (s <> 10000) then
begin
if ((deepmax - depth) mod 2 = 0) then
begin
if (value2 < s) then
begin
value2 := s; value[depth] := value2;
chesspath[deepmax - runsteps] := chr(64 + cango[i].x) + inttostr(cango[i].y);
end;
end
else
begin
if (value2 > s) then
begin
value2 := s; value[depth] := value2;
chesspath[deepmax - runsteps] := chr(64 + cango[i].x) + inttostr(cango[i].y);
end;
end;
if (depth = deepmax) then
begin
chesspath[0] := chr(64 + cango[i].x) + inttostr(cango[i].y);
saveva[evapoint].max := s;
saveva[evapoint].x := cango[i].x;
saveva[evapoint].y := cango[i].y;
for m := 0 to deepmax - 1 do
saveva[evapoint].path := saveva[evapoint].path + chesspath[m];
inc(evapoint);
if (value2 > max) then
begin
max := value2;
max_x := cango[i].x;
max_y := cango[i].y;
end;
end;
end;
if last <> 1 then
begin
addflag := savaddflag;
for m := 1 to 8 do
for n := 1 to 8 do
begin
//ichess[m,n]:=pus[m,n];
cost[m, n] := savcost[m, n];
end;
end;
//addleft:=savaddl;
//addright:=savaddr;
//addtop:=savaddu;
//addbot:=savaddd;
if savcolor = compcolor then
begin
ichess[cango[i].x, cango[i].y] := none;
if savl <> 0 then for m := 1 to savl do ichess[cango[i].x - m, cango[i].y] := mancolor;
if savr <> 0 then for m := 1 to savr do ichess[cango[i].x + m, cango[i].y] := mancolor;
if savu <> 0 then for m := 1 to savu do ichess[cango[i].x, cango[i].y - m] := mancolor;
if savd <> 0 then for m := 1 to savd do ichess[cango[i].x, cango[i].y + m] := mancolor;
if savlu <> 0 then for m := 1 to savlu do ichess[cango[i].x - m, cango[i].y - m] := mancolor;
if savld <> 0 then for m := 1 to savld do ichess[cango[i].x - m, cango[i].y + m] := mancolor;
if savru <> 0 then for m := 1 to savru do ichess[cango[i].x + m, cango[i].y - m] := mancolor;
if savrd <> 0 then for m := 1 to savrd do ichess[cango[i].x + m, cango[i].y + m] := mancolor;
end
else
begin
ichess[cango[i].x, cango[i].y] := none;
if savl <> 0 then for m := 1 to savl do ichess[cango[i].x - m, cango[i].y] := compcolor;
if savr <> 0 then for m := 1 to savr do ichess[cango[i].x + m, cango[i].y] := compcolor;
if savu <> 0 then for m := 1 to savu do ichess[cango[i].x, cango[i].y - m] := compcolor;
if savd <> 0 then for m := 1 to savd do ichess[cango[i].x, cango[i].y + m] := compcolor;
if savlu <> 0 then for m := 1 to savlu do ichess[cango[i].x - m, cango[i].y - m] := compcolor;
if savld <> 0 then for m := 1 to savld do ichess[cango[i].x - m, cango[i].y + m] := compcolor;
if savru <> 0 then for m := 1 to savru do ichess[cango[i].x + m, cango[i].y - m] := compcolor;
if savrd <> 0 then for m := 1 to savrd do ichess[cango[i].x + m, cango[i].y + m] := compcolor;
end;
//else
//for m:=1 to 8 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -