Hi,
I'm thinking on adding a mate searching thread to my checkers engine.
In checkers there is no mate but I'll use the word mate to speak the chess language.
With so much forward pruning going on in my engine some short wining lines are not detected until a very large nominal depth is reached. Just like some chess engines in the past going 30+ plies deep but failing to see mate in 10.
So at the tips of the search tree when I'm ready to return the eval (qsearch), and assuming the current position has valid moves, what should I return?
1 - zero
2 - alpha
3 - basic PST
I would appreciate your thoughts on this.
thanks,
Alvaro
Adding a mate searching thread to my engine
Moderator: Ras
-
- Posts: 363
- Joined: Thu Mar 16, 2006 7:39 pm
- Location: Portugal
- Full name: Alvaro Cardoso
-
- Posts: 313
- Joined: Tue Aug 03, 2021 2:41 pm
- Full name: Bill Beame
Re: Adding a mate searching thread to my engine
My objective is mate in minimum moves in minimum time. There are only 2 pruning variables, enemy king moves > 5 and checkmate. All others pruning variables fail at least once in simulations of 100,000 known checkmates. Bottom line, if you prune you will miss something. Also, using known checkmates verifies your engine's accuracy. There is a huge time penalty for this objective; however, when quantum computing becomes the norm, an optimized algorithm will become unbeatable.Cardoso wrote: ↑Wed Apr 06, 2022 10:55 pm Hi,
I'm thinking on adding a mate searching thread to my checkers engine.
In checkers there is no mate but I'll use the word mate to speak the chess language.
With so much forward pruning going on in my engine some short wining lines are not detected until a very large nominal depth is reached. Just like some chess engines in the past going 30+ plies deep but failing to see mate in 10.
So at the tips of the search tree when I'm ready to return the eval (qsearch), and assuming the current position has valid moves, what should I return?
1 - zero
2 - alpha
3 - basic PST
I would appreciate your thoughts on this.
thanks,
Alvaro
-
- Posts: 1062
- Joined: Tue Apr 28, 2020 10:03 pm
- Full name: Daniel Infuehr
Re: Adding a mate searching thread to my engine
Let me answer this straightforward:
Return 0 at the leafs.
Remove all pruning.
You will end up with pure alphabeta which should be around 7 lines of code and will find forced wins for you.
If that recursion returns a win it is a forced win IE mate in X
You can still do iterative deepening when the number of open paths remain low
Return 0 at the leafs.
Remove all pruning.
You will end up with pure alphabeta which should be around 7 lines of code and will find forced wins for you.
If that recursion returns a win it is a forced win IE mate in X
You can still do iterative deepening when the number of open paths remain low
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Daniel Inführ - Software Developer
-
- Posts: 313
- Joined: Tue Aug 03, 2021 2:41 pm
- Full name: Bill Beame
Re: Adding a mate searching thread to my engine
]dangi12012 wrote: ↑Thu Apr 07, 2022 8:53 pm Let me answer this straightforward:
Return 0 at the leafs.
Remove all pruning.
You will end up with pure alphabeta which should be around 7 lines of code and will find forced wins for you.
If that recursion returns a win it is a forced win IE mate in X
You can still do iterative deepening when the number of open paths remain low
AI tools, alpha/beta, Zobirst hash, evaluation function.
The evaluation function is the most critical requirement to speeding up the search. I found 7 significant variables which needs to be optimized using a nonlinear search.
1. single check, double check, discovered check
2. history by ply
3. captured piece type
4. pawn promotion
5. piece type moved
6 number of enemy king moves
7. ent passant
-
- Posts: 467
- Joined: Fri Dec 16, 2016 11:04 am
- Location: France
- Full name: Richard Delorme
Re: Adding a mate searching thread to my engine
I think you should return 3 - basic PST, or even the eval if it is not too slow. One problem is to remove the forward pruning to make the search not selective in the solving thread and to detect when the search is selective or not in the hash table.Cardoso wrote: ↑Wed Apr 06, 2022 10:55 pm Hi,
I'm thinking on adding a mate searching thread to my checkers engine.
In checkers there is no mate but I'll use the word mate to speak the chess language.
With so much forward pruning going on in my engine some short wining lines are not detected until a very large nominal depth is reached. Just like some chess engines in the past going 30+ plies deep but failing to see mate in 10.
So at the tips of the search tree when I'm ready to return the eval (qsearch), and assuming the current position has valid moves, what should I return?
1 - zero
2 - alpha
3 - basic PST
I would appreciate your thoughts on this.
thanks,
Alvaro
Richard Delorme
-
- Posts: 363
- Joined: Thu Mar 16, 2006 7:39 pm
- Location: Portugal
- Full name: Alvaro Cardoso
Re: Adding a mate searching thread to my engine
So no heuristics that could possibly help?dangi12012 wrote: ↑Thu Apr 07, 2022 8:53 pm Let me answer this straightforward:
Return 0 at the leafs.
Remove all pruning.
You will end up with pure alphabeta which should be around 7 lines of code and will find forced wins for you.
If that recursion returns a win it is a forced win IE mate in X
You can still do iterative deepening when the number of open paths remain low
About pruning, maybe the only pruning I can make safely is mate distance pruning. I'm going to test that.
-
- Posts: 969
- Joined: Fri Mar 10, 2006 4:29 pm
- Location: Germany
- Full name: Jörg Oster
Re: Adding a mate searching thread to my engine
You will end up with something able to solve mates in 4 or even up to mates in 7 in reasonable time.dangi12012 wrote: ↑Thu Apr 07, 2022 8:53 pm Let me answer this straightforward:
Return 0 at the leafs.
Remove all pruning.
You will end up with pure alphabeta which should be around 7 lines of code and will find forced wins for you.
If that recursion returns a win it is a forced win IE mate in X
You can still do iterative deepening when the number of open paths remain low
Longer mates will take forever without additional pruning heuristics.
Jörg Oster
-
- Posts: 1275
- Joined: Wed Mar 08, 2006 8:28 pm
- Location: Florida, USA
Re: Adding a mate searching thread to my engine
It's an interesting idea. Here's what I'd do:
Have one thread that is "tactical" and given search parameters alpha = (Mate - Max_Ply), beta = Mate i.e. in the mate range. Have it search normally with the standard pruning techniques. I suspect the hash table is where the magic comes in: don't store the results of this search unless the score is a mate score. Assuming you're using lazy SMP the other threads will then be guided by the hash table only if there is a mate to be found. Since you're only storing mate scores you won't clutter the hash table with irrelevant not-mate bounds.
I've no idea if it'll work but it's worth a try.
Steve
Have one thread that is "tactical" and given search parameters alpha = (Mate - Max_Ply), beta = Mate i.e. in the mate range. Have it search normally with the standard pruning techniques. I suspect the hash table is where the magic comes in: don't store the results of this search unless the score is a mate score. Assuming you're using lazy SMP the other threads will then be guided by the hash table only if there is a mate to be found. Since you're only storing mate scores you won't clutter the hash table with irrelevant not-mate bounds.
I've no idea if it'll work but it's worth a try.
Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
-
- Posts: 1062
- Joined: Tue Apr 28, 2020 10:03 pm
- Full name: Daniel Infuehr
Re: Adding a mate searching thread to my engine
Yes. Its the way to go for mate search.Joerg Oster wrote: ↑Fri Apr 08, 2022 10:47 amYou will end up with something able to solve mates in 4 or even up to mates in 7 in reasonable time.dangi12012 wrote: ↑Thu Apr 07, 2022 8:53 pm Let me answer this straightforward:
Return 0 at the leafs.
Remove all pruning.
You will end up with pure alphabeta which should be around 7 lines of code and will find forced wins for you.
If that recursion returns a win it is a forced win IE mate in X
You can still do iterative deepening when the number of open paths remain low
Longer mates will take forever without additional pruning heuristics.
Any pruning and you will lose otherwise found mates.
Its a simple also educational task since its a few lines of code. Should be quite beautiful
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Daniel Inführ - Software Developer
-
- Posts: 363
- Joined: Thu Mar 16, 2006 7:39 pm
- Location: Portugal
- Full name: Alvaro Cardoso
Re: Adding a mate searching thread to my engine
Well if I revisit an interior node one or more times, that takes a billion nodes to search I really wouldn't like to repeat the same search again for this subtree, so I have to use the hash table for non mating/mated positions also. What I could do is to give precedence for mating positions in the hash table replacing scheme. What do you think Steve?Steve Maughan wrote: ↑Fri Apr 08, 2022 12:59 pm It's an interesting idea. Here's what I'd do:
Have one thread that is "tactical" and given search parameters alpha = (Mate - Max_Ply), beta = Mate i.e. in the mate range. Have it search normally with the standard pruning techniques. I suspect the hash table is where the magic comes in: don't store the results of this search unless the score is a mate score. Assuming you're using lazy SMP the other threads will then be guided by the hash table only if there is a mate to be found. Since you're only storing mate scores you won't clutter the hash table with irrelevant not-mate bounds.
I've no idea if it'll work but it's worth a try.
Steve