Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Here's my Alpha-Beta source code

Author: Tony Werten

Date: 23:48:18 09/09/03

Go up one level in this thread


On September 09, 2003 at 21:54:53, Jose Santos wrote:

>Hi,
>
>>welcome to the chess programmer community. I have just added your download >links to my new link page for Pascal/Delphi chess programmers
>>http://wbholmes.de/links_pascal.htm. I hope your links are not temporary.
>
>Thanks. I've just gone there. There's a HUGE amount of it. I downloaded and
>tested some programs (not yours yet).
>
>The links are not temporary. I'll post new versions on those links.
>By the way I didn't mention but I also have a DOS version. It's here:
>http://ctp.di.fct.unl.pt/~jcas/chessdos.exe
>As you can guess this version was compiled with Free Pascal (1.1) and hence is
>about 40% slower than Win32 version which was compiled with Delphi 7. Linux
>version was compiled with Kylix 3.
>
>
>>To your problem: Perhaps an error in your AlphaBeta algorythm. You should >post a part of it here for a better help.
>
>Ok, here's my min-max

No it isn't. It's alpha beta. And AB will make the difference between scores
smaller.

Say there are 2 moves with score>beta ( on a max node). Minimax will always
return the biggest score of the 2. AB might return the smaller one. When this
happens all over the search, the differences become smaller.

If you want to have pure minimax you should remove the 2 break conditions and
not update alpha or beta ( But you will not reach 6 ply in most positions).

Tony

>
>  function MiniMax(CurDepth: Integer; Alpha, Beta: Integer): Integer;
>  //MaxNode is true when CurDepth is Even.
>  //At odd depths we are at min nodes (opponent nodes)
>  //With alpha-beta cuts!
>  var
>    Value: Integer;
>    I: Integer;
>    Moves: TMoves;
>  begin
>    if (CurDepth = MaxDepth) or (Board.KingTaken) then
>    begin
>      Inc(PositionsEvaluated);
>      //don't forget evaluation function gives a positive
>      //number if advantage is for white so we have to check that
>      if Color=White then
>        Result:=Evaluate
>      else//Color=Black
>        Result:=-Evaluate;
>    end else if Odd(CurDepth) then //if we are in a min node
>    begin
>      Moves:=Board.GetPossibleMoves(OppositeColor(Color));//opponent turn
>      for I:=1 to Moves.CountMoves do
>      begin
>        Board.DoMove(Moves.GetMove(I));
>        Value:=MiniMax(CurDepth+1, Alpha, Beta);
>        Board.UndoLastMove;
>        if Value < Beta then
>          Beta:=Value;
>          if Beta <= Alpha then
>            break;
>      end;
>      Moves.Free;
>      Result:=Beta;
>    end else//MaxNode
>    begin
>      Moves:=Board.GetPossibleMoves(Color);//this is my turn
>      for I:=1 to Moves.CountMoves do
>      begin
>        Board.DoMove(Moves.GetMove(I));
>        Value:=MiniMax(CurDepth+1, Alpha, Beta);
>        Board.UndoLastMove;
>        if Value > Alpha then
>        begin
>          Alpha:=Value;
>          if CurDepth=0 then//update best move
>            BestMove:=Moves.GetMove(I);
>        end;
>        if Alpha >= Beta then
>          break;
>      end;
>      Moves.Free;
>      Result:=Alpha;
>    end;
>  end;
>
>Is there a problem not to generate the main variation and do
>    if CurDepth=0 then//update best move
>      BestMove:=Moves.GetMove(I);
>
>?
>
>I don't think so but I also don't like much my solution.
>
>Have you tried my program ?
>
>Regards,
>
>
>                                            Jose Santos



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.