Finding Tactics in the Search

Discussion of chess software programming and technical issues.

Moderator: Ras

Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Finding Tactics in the Search

Post by Mike Sherwin »

While watching online, events like the 2022 candidates tournament and other high level events I noticed that GMs use tactic recognition to shape their search space. And usually the stronger the GM is the better they are at seeing tactics in the search space.

I believe that a chess engine can benefit as well by finding tactics during the search and using that information to better shape the search space. But how to go about that? In the lower plies of the search tree two scores can be generated. A quiet score by just calling qScore = Qsearch() for each possible move as an expected score and a tScore = Tsearch() (tactical search) that is like a Qsearch except each side is allowed to insert one move at any place in the Tsearch(). Then depth extensions, reductions or even forward pruning can be done.
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Finding Tactics in the Search

Post by algerbrex »

Do you propose using these two values for move ordering? Won't calling qsearch to order every move be expensive? Same for search? Just curious because I'm not sure I fully understand what you're proposing here, but it sounds like an interesting idea to me.

Intuitively to me, having the qsearch value of a move to use in order it would be great, basically, SEE on steroids. But the slowdown presented by using qsearch in such a way would be even worse than SEE, I'd imagine to the point where any benefit would be lost.
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Finding Tactics in the Search

Post by Mike Sherwin »

algerbrex wrote: Mon Jun 27, 2022 1:23 am Do you propose using these two values for move ordering? Won't calling qsearch to order every move be expensive? Same for search? Just curious because I'm not sure I fully understand what you're proposing here, but it sounds like an interesting idea to me.

Intuitively to me, having the qsearch value of a move to use in order it would be great, basically, SEE on steroids. But the slowdown presented by using qsearch in such a way would be even worse than SEE, I'd imagine to the point where any benefit would be lost.
I already use 1 move + qsearch in RomiChess to order the remaining moves if depth > 3. It works great. Added to TSCP it averaged ~1.5 ply deeper searches. But that alone will not find a tactic. A tactic is found by inserting a non capture that is a fork or a pin. I propose inserting a non capture for each side to find tactics and then use that information to shape the search space. A tactic is found if qScore and tScore are not close. It won't be expensive if only done at lower plies.
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Finding Tactics in the Search

Post by algerbrex »

Mike Sherwin wrote: Mon Jun 27, 2022 8:10 am I already use 1 move + qsearch in RomiChess to order the remaining moves if depth > 3. It works great. Added to TSCP it averaged ~1.5 ply deeper searches.
Interesting, I might experiment with that idea a bit. It seemed to me like a bit of an optimistic approach, but if it works well in practice, well, it doesn't really matter much what I theorize does it :lol:

So to make sure I understand you correctly, in place of any other move ordering at depth > 3, you did a depth=1 search on each move to be searched and sorted them using their respective scores returned from the search?
Mike Sherwin wrote: Mon Jun 27, 2022 8:10 am But that alone will not find a tactic. A tactic is found by inserting a non capture that is a fork or a pin. I propose inserting a non capture for each side to find tactics and then use that information to shape the search space. A tactic is found if qScore and tScore are not close. It won't be expensive if only done at lower plies.
I think I see a little more of what you mean. How exactly do you envision the mechanics of this? I'm still a little confused about how a quiet move is selected, and then inserted into the search sequence of Search? I understand from your first post tSearch is like qSearch, but what are the mechanics that allow a side to intelligently select where in the search sequence to insert a move?
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Finding Tactics in the Search

Post by Mike Sherwin »

algerbrex wrote: Mon Jun 27, 2022 11:26 pm
Mike Sherwin wrote: Mon Jun 27, 2022 8:10 am I already use 1 move + qsearch in RomiChess to order the remaining moves if depth > 3. It works great. Added to TSCP it averaged ~1.5 ply deeper searches.
Interesting, I might experiment with that idea a bit. It seemed to me like a bit of an optimistic approach, but if it works well in practice, well, it doesn't really matter much what I theorize does it :lol:

So to make sure I understand you correctly, in place of any other move ordering at depth > 3, you did a depth=1 search on each move to be searched and sorted them using their respective scores returned from the search?
Mike Sherwin wrote: Mon Jun 27, 2022 8:10 am But that alone will not find a tactic. A tactic is found by inserting a non capture that is a fork or a pin. I propose inserting a non capture for each side to find tactics and then use that information to shape the search space. A tactic is found if qScore and tScore are not close. It won't be expensive if only done at lower plies.
I think I see a little more of what you mean. How exactly do you envision the mechanics of this? I'm still a little confused about how a quiet move is selected, and then inserted into the search sequence of Search? I understand from your first post tSearch is like qSearch, but what are the mechanics that allow a side to intelligently select where in the search sequence to insert a move?
The call for Tsearch would look like tScore = -Tsearch(-beta - MARGINE, -alpha + MARGINE, 1, 1) {} where the first 1 is white's permission to generate non captures and the second 1 is black's permission to generate non captures. If any non capture is made that sides 1 becomes a 0 and that side can no longer generate non captures.

For move ordering with 1 ply + Qsearch use a widened window -beta -100, -alpha + 100, works well. Also calling regular search again with depth of 1 works well also.