📄 ueval.pas
字号:
//for n:=1 to 8 do
//begin
//ichess[m,n]:=pus[m,n];
//end;
end;
begin //节点初始化
if can <> -1 then can := 0;
if (deepmax - depth) mod 2 = 0 then
begin value2 := -9000; value[depth] := -9000; end
else
begin value2 := 9000; value[depth] := 9000; end;
if depth = deepmax then max := -9999;
chesspath[deepmax - depth] := '';
if (((runsteps <= 0) or (steps = 65)) and (addflag = 0)) or (runsteps <= -1) then //是叶子节点
//if (runsteps=0) or (steps=65) then //是叶子节点
begin
//------------------------branch
inc(branch);
if branch mod 10000 = 0 then
begin
mainfrm.statusbar1.Panels.Items[1].text := '推理分枝数:' + inttostr(branch div 10000) + '0K';
mainfrm.statusbar1.Refresh;
end;
//------------------------end branch
//叶子节点返回值
a := countvalue;
if ((deepmax - depth) mod 2 = 0) and (depth <> deepmax) then
begin
for k := deepmax div 2 downto 1 do
if (depth + k * 2 <= deepmax) then
begin
if a <= value[depth + k * 2] then
begin
cut := 1;
break;
end;
end;
end
else if ((deepmax - depth) mod 2 = 1) and (depth <> deepmax - 1) then
begin
for k := deepmax div 2 downto 1 do
if (depth + k * 2 <= deepmax) then
begin
if a >= value[depth + k * 2] then
begin
cut := 1;
break;
end;
end;
end;
result := a;
exit;
end;
//扫描判断
point := 1;
for j := 1 to 8 do
for i := 1 to 8 do
begin
if last = 1 then
begin
if ichess[i, j] <> none then continue;
if ((deepmax - depth) mod 2 = 0) then
changechess(i, j, compcolor, 0)
else
changechess(i, j, mancolor, 0);
if chessable = 1 then
begin
cango[point].x := i;
cango[point].y := j;
cango[point].value := 20;
if ((i = 1) and (j = 1)) or ((i = 8) and (j = 1)) or ((i = 8) and (j = 8)) or ((i = 1) and (j = 8)) then cango[point].value := 30;
if (ichess[i - 1, j] = none) and (i > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i, j - 1] = none) and (j > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j] = none) and (i < 8) then cango[point].value := cango[point].value - 1;
if (ichess[i, j + 1] = none) and (j < 8) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j - 1] = none) and (i > 1) and (j > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j + 1] = none) and (i < 8) and (j < 8) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j - 1] = none) and (i < 8) and (j > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j + 1] = none) and (i > 1) and (j < 8) then cango[point].value := cango[point].value - 1;
inc(point);
end;
end
else
begin
if ichess[i, j] <> none then continue;
if ((deepmax - depth) mod 2 = 0) then
changechess(i, j, compcolor, 3)
else
changechess(i, j, mancolor, 3);
if chessable = 1 then
begin
chesscount := l + r + u + d + lu + ld + ru + rd;
cango[point].x := i;
cango[point].y := j;
cango[point].value := 20;
if ((i = 1) and (j = 1)) or ((i = 8) and (j = 1)) or ((i = 8) and (j = 8)) or ((i = 1) and (j = 8)) then cango[point].value := 30
else if ((i = 2) and (j = 2)) or ((i = 7) and (j = 2)) or ((i = 7) and (j = 7)) or ((i = 2) and (j = 7)) then cango[point].value := 10
else if ((i = 2) and (j = 1) and (ichess[3, 1] = mancolor)) or ((i = 1) and (j = 2) and (ichess[1, 3] = mancolor)) or ((i = 2) and (j = 8) and (ichess[3, 8] = mancolor)) or ((i = 8) and (j = 2) and (ichess[8, 3] = mancolor)) or ((i = 7) and (j = 1) and (ichess[6, 1] = mancolor)) or ((i = 7) and (j = 8) and (ichess[6, 8] = mancolor)) or ((i = 1) and (j = 7) and (ichess[1, 6] = mancolor)) or ((i = 8) and (j = 7) and (ichess[8, 6] = mancolor)) then cango[point].value := 7;
if (ichess[i - 1, j] = none) and (i > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i, j - 1] = none) and (j > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j] = none) and (i < 8) then cango[point].value := cango[point].value - 1;
if (ichess[i, j + 1] = none) and (j < 8) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j - 1] = none) and (i > 1) and (j > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j + 1] = none) and (i < 8) and (j < 8) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j - 1] = none) and (i < 8) and (j > 1) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j + 1] = none) and (i > 1) and (j < 8) then cango[point].value := cango[point].value - 1;
if (l <> 0) and (j <> 1) and (j <> 8) then
for k := 1 to l do
begin
if (ichess[i - 1 - k, j] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - k, j - 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - k, j + 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 - k, j - 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j + 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j - 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 - k, j + 1] = none) then cango[point].value := cango[point].value - 1;
end;
if (r <> 0) and (j <> 1) and (j <> 8) then
for k := 1 to r do
begin
if (ichess[i - 1 + k, j] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + k, j - 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + k, j + 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 + k, j - 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j + 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j - 1] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 + k, j + 1] = none) then cango[point].value := cango[point].value - 1;
end;
if (u <> 0) and (i <> 1) and (i <> 8) then
for k := 1 to u do
begin
if (ichess[i - 1, j - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
end;
if (d <> 0) and (i <> 1) and (i <> 8) then
for k := 1 to d do
begin
if (ichess[i - 1, j + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
end;
if lu <> 0 then
for k := 1 to lu do
begin
if (ichess[i - 1 - k, j - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - k, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - k, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 - k, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 - k, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
end;
if ld <> 0 then
for k := 1 to ld do
begin
if (ichess[i - 1 - k, j + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - k, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - k, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 - k, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 - k, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 - k, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
end;
if ru <> 0 then
for k := 1 to ru do
begin
if (ichess[i - 1 + k, j - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + k, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + k, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 + k, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j - 1 - k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 + k, j + 1 - k] = none) then cango[point].value := cango[point].value - 1;
end;
if rd <> 0 then
for k := 1 to rd do
begin
if (ichess[i - 1 + k, j + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + k, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + k, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 + k, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i + 1 + k, j - 1 + k] = none) then cango[point].value := cango[point].value - 1;
if (ichess[i - 1 + k, j + 1 + k] = none) then cango[point].value := cango[point].value - 1;
end;
cango[point].value := cango[point].value - chesscount div 5;
inc(point);
end;
end;
end;
//sort(cango);
//
if ram then
for j := 1 to point - 2 do begin
for i := 1 to point - j - 1 do begin
if random(20) < 10 then
begin
if cango[i].value <= cango[i + 1].value then
begin
temp.value := cango[i].value;
temp.x := cango[i].x;
temp.y := cango[i].y;
cango[i].value := cango[i + 1].value;
cango[i].x := cango[i + 1].x;
cango[i].y := cango[i + 1].y;
cango[i + 1].value := temp.value;
cango[i + 1].x := temp.x;
cango[i + 1].y := temp.y;
end;
end
else
begin
if cango[i].value < cango[i + 1].value then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -