Computer Chess Club Archives


Search

Terms

Messages

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

Author: Andreas Herrmann

Date: 20:32:46 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.

Ok, thanks.

>
>
>>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
>
>  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;

To your source excample: It's a bit different then others do AlphaBeta. I don't
know if your solution works correct.
Some remarks:
Why not
       Value := -MiniMax(CurDepth+1,-Beta, -Alpha);
... then you don't need to differ between odd and even.

Most others and i do the search with the distance to the horizont:
excample:       Value := -MiniMax(distance-1,-Beta, -Alpha);
Then you can call your qsearch if distance <= 0
But i can't see a qsearch call in your code. Do you do that inside Evaluate?

Perhaps you have a look to other sources like Crafty, to see how they do the
search.
To test your minmax without cut offs i would try it first with a full open
window (Alpha := -infinite  Beta := infinite).

Sorry that i can't help you more. Well i can help you with some good links to
AlphaBeta search. See the following:

http://www.seanet.com/~brucemo/topics/alphabeta.htm
http://www.xs4all.nl/~verhelst/chess/search.html
http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic11/


>
>Is there a problem not to generate the main variation and do
>    if CurDepth=0 then//update best move
>      BestMove:=Moves.GetMove(I);

Off course this works, but it would be better to generate a main variation, then
you could see what your search produces.

>
>?
>
>I don't think so but I also don't like much my solution.
>
>Have you tried my program ?
>
Sorry i have started it only one time without a closer look. At the moment i'm
working on some components and object classes for my coming own GUI. So i have
not much time.


good luck
Andreas


>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.