⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ueval.pas

📁 象棋源码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
          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;
      end; end
  else
    for j := 1 to point - 2 do begin
      for i := 1 to point - j - 1 do 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; end;


  if point <> 1 then
  begin
    for i := 1 to point - 1 do
    begin
      flag := false;
      getmax2;
      if flag then
        if (cut = 1) then
        begin
          cut := 0; result := 10000; exit;
        end;
    end;
  end;

  if (depth <> deepmax) then
  begin
    if can = 0 then //有一方不能下
    begin
      dec(depth);
      dec(can);
      s := getmax();

      can := 0;
      inc(depth);
      if (cut = 1) then
      begin
        cut := 0; result := 10000; exit;
      end;
      if (s <> 10000) then
      begin
        if ((deepmax - depth) mod 2 = 0) then
        begin
          if (value2 < s) then
          begin
            value2 := s;
            value[depth] := s;
          end;
        end
        else
        begin
          if (value2 > s) then
          begin
            value2 := s;
            value[depth] := s;
          end;
        end;
      end;
    end;
  end;

  if (can = -1) 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
    countchess();
    if (iblcount > iwhcount) then
    begin
      if last <> 1 then value2 := 112.8
      else
        value2 := iblcount - iwhcount
    end;
    if (iblcount < iwhcount) then
    begin
      if last <> 1 then value2 := -112.8
      else
        value2 := iblcount - iwhcount
    end; ;
    if (iblcount = iwhcount) then
      value2 := 0;
    can := 0;
  end;

  b := value2; //非叶子节点返回值

  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 b <= 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 b >= value[depth + k * 2] then
        begin
          cut := 1;
          break;
        end;
      end;
  end;
  if b = 9000 then b := -9000
  else if b = -9000 then b := 9000;
  result := b;

end;

function countvalue: real;
var
  i, j: integer;
  wg, bg: integer;
  vb, vw: integer;
  temp: real;
begin

  vb := 0; vw := 0;
  if last = 1 then
  begin
    for i := 1 to 8 do begin
      for j := 1 to 8 do begin
        if (ichess[i, j] = compcolor) then inc(vb);
        if (ichess[i, j] = mancolor) then inc(vw);
      end; end;
    result := vb - vw;
    exit;
  end;

  wg := 0; bg := 0;
//if last2<>1 then
  changecost();


  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      if (ichess[i, j] = compcolor) then vb := vb + cost[i, j];
      if (ichess[i, j] = mancolor) then vw := vw + cost[i, j];
    end; end;

//getstably;
//vb:=round((64-stablycomp-stablyman)/64*vb)+stablycomp;
//vw:=round((64-stablycomp-stablyman)/64*vw)+stablyman;

  for i := 1 to 8 do begin
    for j := 1 to 8 do begin
      if (not ((i = 2) and (j = 2))) and (not ((i = 2) and (j = 7))) and (not ((i = 7) and (j = 2))) and (not ((i = 7) and (j = 7))) then
      begin
        changechess(i, j, compcolor, 0);
        if chessable <> 0 then
        begin
          if last2 <> 1 then
          begin
            if (i = 1) and (j = 2) and (ichess[1, 1] = none) then begin if ichess[1, 3] <> mancolor then inc(bg); end
            else if (i = 2) and (j = 1) and (ichess[1, 1] = none) then begin if ichess[3, 1] <> mancolor then inc(bg); end
            else if (i = 7) and (j = 1) and (ichess[8, 1] = none) then begin if ichess[6, 1] <> mancolor then inc(bg); end
            else if (i = 1) and (j = 7) and (ichess[1, 8] = none) then begin if ichess[1, 6] <> mancolor then inc(bg); end
            else if (i = 8) and (j = 2) and (ichess[8, 1] = none) then begin if ichess[8, 3] <> mancolor then inc(bg); end
            else if (i = 2) and (j = 8) and (ichess[1, 8] = none) then begin if ichess[3, 8] <> mancolor then inc(bg); end
            else if (i = 8) and (j = 7) and (ichess[8, 8] = none) then begin if ichess[8, 6] <> mancolor then inc(bg); end
            else if (i = 7) and (j = 8) and (ichess[8, 8] = none) then begin if ichess[6, 8] <> mancolor then inc(bg); end
            else
              inc(bg);
          end
          else
            inc(bg);
        end;
        changechess(i, j, mancolor, 0);
        if chessable <> 0 then
        begin
          if last2 <> 1 then
          begin
            if (i = 1) and (j = 2) and (ichess[1, 1] = none) then begin if ichess[1, 3] <> compcolor then inc(wg); end
            else if (i = 2) and (j = 1) and (ichess[1, 1] = none) then begin if ichess[3, 1] <> compcolor then inc(wg); end
            else if (i = 7) and (j = 1) and (ichess[8, 1] = none) then begin if ichess[6, 1] <> compcolor then inc(wg); end
            else if (i = 1) and (j = 7) and (ichess[1, 8] = none) then begin if ichess[1, 6] <> compcolor then inc(wg); end
            else if (i = 8) and (j = 2) and (ichess[8, 1] = none) then begin if ichess[8, 3] <> compcolor then inc(wg); end
            else if (i = 2) and (j = 8) and (ichess[1, 8] = none) then begin if ichess[3, 8] <> compcolor then inc(wg); end
            else if (i = 8) and (j = 7) and (ichess[8, 8] = none) then begin if ichess[8, 6] <> compcolor then inc(wg); end
            else if (i = 7) and (j = 8) and (ichess[8, 8] = none) then begin if ichess[6, 8] <> compcolor then inc(wg); end
            else
              inc(wg);
          end
          else
            inc(wg);
        end;
      end; end; end;
{    if abs(vb-vw)<10 then
    temp:=round(sqrt(bg*80)-sqrt(wg*80))+addvalue
    else if abs(vb-vw)<30 then
    temp:=round(sqrt(bg*80)-sqrt(wg*80))*2+addvalue
    else if abs(vb-vw)<60 then
    temp:=round(sqrt(bg*80)-sqrt(wg*480))*4+addvalue
    else if abs(vb-vw)<150 then
    temp:=round(sqrt(bg*80)-sqrt(wg*80))*8+addvalue
    else
    temp:=round(sqrt(bg*80)-sqrt(wg*80))*16+addvalue;
if vb-vw+temp>=0 then
result:=round(sqrt(vb-vw+temp)*100)/50
else
result:=-round(sqrt(vw-vb-temp)*100)/50;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -