Help please with alpha-beta

Discussion of chess software programming and technical issues.

Moderator: Ras

AlvaroBegue
Posts: 932
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Help please with alpha-beta

Post by AlvaroBegue »

Alexandr Novikov wrote:i think i have good move generator. my program analyzes over 2 000 000 positions per second on my core i7 in single mode. i used mac mashine with parallels desktop for chess programming
At this stage the speed of your move generator is irrelevant. Is it bug free? Write a perft function to find out!

http://chessprogramming.wikispaces.com/perft
User avatar
Volker Annuss
Posts: 181
Joined: Mon Sep 03, 2007 9:15 am

Re: Help please with alpha-beta

Post by Volker Annuss »

Henk wrote:I remember a teacher at school having trouble with explaining code of towers of Hanoi problem.
That's completely off topic. The towers of Hanoi don't even have to do with recursion. :D

Just move the smallest piece counterclockwise when the number of pieces is even (clockwise when the number of pieces is odd) every 2nd move and make the only possible move that does not involve the smallest piece every other move.
Alexandr Novikov
Posts: 22
Joined: Tue Sep 15, 2015 8:21 pm

Re: Help please with alpha-beta

Post by Alexandr Novikov »

i not used perft, but i'm sure, that my move gen bugs free on 99 percent.
Dann Corbit
Posts: 12838
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Help please with alpha-beta

Post by Dann Corbit »

On the other hand, the first time I solved the towers of Hanoi, I did it recursively.

There is a wonderful dialog on the towers of Hanoi in Sedgewick, and he shows how the solution to this problem can also be used for such things are marking the increments on a ruler properly.
Dann Corbit
Posts: 12838
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Help please with alpha-beta

Post by Dann Corbit »

It is also true that solving N! using recursion is utter stupidity (iteration is faster and a table is even better).

On the other hand, it is such a simple example that using it to illustrate recursion is a good idea.
AlvaroBegue
Posts: 932
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Help please with alpha-beta

Post by AlvaroBegue »

Alexandr Novikov wrote:i not used perft, but i'm sure, that my move gen bugs free on 99 percent.
Are you willing to take a bet where I give you $10 if your code is correct and you give me $1000 if it's buggy?
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Help please with alpha-beta

Post by Sven »

Alexandr Novikov wrote:Variable depth is ply in my code?
In this code example "depth" means remaining depth until horizon. In your code "ply" means the distance from root to current node. When starting search at the root with depth=5, initially you are at ply=0. After making one move you are at ply=1, and you (normally) search its subtree with depth=4. Another three plies later you are at ply=4 and search with depth=1. Etc. I wrote "normally" since you might decide to search the current node to a higher or lower depth (this is for later).
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Help please with alpha-beta

Post by Sven »

AlvaroBegue wrote:
Alexandr Novikov wrote:i not used perft, but i'm sure, that my move gen bugs free on 99 percent.
Are you willing to take a bet where I give you $10 if your code is correct and you give me $1000 if it's buggy?
$990 would be fair ;-)

Of course he will take the bet, after having implemented perft it will become an easy $10 gain ...

@Alexandr: We all seriously suggest not to go on without verifying your move generator using perft. The 1% uncertainty will most probably show some en passant, castling, promotion, or legality problem in some "very rare" cases. Unfortunately that would affect the quality of your search as well, not only due to possible illegal moves (or not all legal moves) and getting wrong results but also in terms of performance (for instance if you search too many replies to a check - this could easily lead to a search explosion).
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Help please with alpha-beta

Post by bob »

Sven Schüle wrote:
Alexandr Novikov wrote:Variable depth is ply in my code?
In this code example "depth" means remaining depth until horizon. In your code "ply" means the distance from root to current node. When starting search at the root with depth=5, initially you are at ply=0. After making one move you are at ply=1, and you (normally) search its subtree with depth=4. Another three plies later you are at ply=4 and search with depth=1. Etc. I wrote "normally" since you might decide to search the current node to a higher or lower depth (this is for later).
I differ a bit. ply = 1 is the root of the tree, where depth=5. By the time I get to ply=5, depth = 0 and that is the last full-width ply of search, next call will be to quiesce rather than search....

IE a move at ply=1 takes me to ply=2, with that move being the FIRST move I search...
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Help please with alpha-beta

Post by Sven »

bob wrote:
Sven Schüle wrote:
Alexandr Novikov wrote:Variable depth is ply in my code?
In this code example "depth" means remaining depth until horizon. In your code "ply" means the distance from root to current node. When starting search at the root with depth=5, initially you are at ply=0. After making one move you are at ply=1, and you (normally) search its subtree with depth=4. Another three plies later you are at ply=4 and search with depth=1. Etc. I wrote "normally" since you might decide to search the current node to a higher or lower depth (this is for later).
I differ a bit. ply = 1 is the root of the tree, where depth=5. By the time I get to ply=5, depth = 0 and that is the last full-width ply of search, next call will be to quiesce rather than search....

IE a move at ply=1 takes me to ply=2, with that move being the FIRST move I search...
That is for Crafty, though, while most others start with 0 at the root. And I guess in the example above you are at depth=1 (not 0) when you get to ply=5.