Is correct this reasoning?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Is correct this reasoning?

Post by Luis Babboni »

cdani wrote:
Luis Babboni wrote: For the moment Soberango not have hash tables neither quiescense search.
You think I must have that before try to solve my actual problem?
Quiescense search is a must to have stable search. If not the engine one time thinks is wining material, and in the next iteration it realizes that is not the case, thus killing move ordering, and move ordering is the abc of alpha beta.

Hash tables once work minimally well, will offer your engine a consistent increase in strenght in each iteration, also a clear improvement in time to depth.
Next schedule step is for iterative deepening, the next one quiescence search but I have fear the way I made the code could have serious problem to do it. :?
Question about it thinking in the moves order, the usual way is to make a list of possible moves before each ply further to search?
Actually Soberango have no idea of all possible moves at any position, just choice one move and go deep first as far as it is determined, evaluate the position reached, and just then return by the tree and test wich other move is possible. (Maybe this deservs a new thread).
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Is correct this reasoning?

Post by Luis Babboni »

hgm wrote: ...
To solve this problem, the 'delayed-loss bonus' was invented:
...
Have most engines this?
User avatar
hgm
Posts: 28461
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Is correct this reasoning?

Post by hgm »

All my engines have it. I don't know anything about other engines.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Is correct this reasoning?

Post by cdani »

Luis Babboni wrote: Question about it thinking in the moves order, the usual way is to make a list of possible moves before each ply further to search?
Is usual to test first alone the possible hash move, and if necessary, follow with at least a partial list of moves, tipically captures ordered by something meaningful, and if none is interesting enough, normal moves. There are a lot ideas and discussions about this, but some are very common.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Is correct this reasoning?

Post by Luis Babboni »

Sorry HG, but I´m still not convenced that iterative deepening not solve this.

Let me try to explain more my reasonig with an example (of course a single example do not proof nothing and you said yet that could be usefull sometimes but sometimes not. But I think the solution to the example you gave me is more related with quiescense search and the purpose of give an example is to be sure you understand my idea):

We are talking of situations where exists a possibilitie of real gain, a situation where if the capture is doing now, the engine gains a piece but if do not capture it now, the opponent could save it.

I think the situation you proposed as an example where the valuation of the position of the king after promotion drives the engine to postponed the capture to push beyond the horizon the better position of the king, I think is a horizon effect that I do not pretend to solve with iterative deepening.
May be my thought is too much influenced by my actual stage of evaluation function... just count material! :oops:

Suppouse the capture could be done in ply 1 or ply 3 but if it is not do it in ply 1, in ply 2 the opponent could made a move that allows it to save the piece.
Example:
[d]4k3/7b/8/1p2ppp1/P4b2/3R2P1/1K1P3P/2B5 w - -
Here Soberango with search depth in 3 (in fact all the discusion here made for depths 1, 2 and 3 could be done for depths 21, 22 and 23), could find as best move axb5 seeing one of this six (wich find first) as best line (remember Soberango just count material and gives 300 cP to bishops):
1) a4xb5-Bxd2;Bxd2 score:+300
2) a4xb5-Bxg3;h2xg3 score:+300
3) g3xB-e5xf4; a4xb5 score:+300
4) g3xB-g5xf4;a4xb5 score:+300
5) g3xB-b5xa4;f4xe5 score:+300
6) g3xB-b5xa4;f4xg5 score:+300
Suppouse then that, just cause find it first and all others gives the same score, Soberango choice 1) axb5?
The opponent do then e4!
Then Soberango needs to save the rook alowing opponent to save the bishop:
For example: axb5-e4!; Rd5-Bc7... score: +100 :(
(Soberango did not saw ...-e4 in the previous move cause ...-e4xR was beyond its depth 3 horizon):
a4xb5-e4?;g3xB score=+400

But with iterative deepening:

When depth=1 the best move is
gxB score:+300

When depth=2 the best move is one of this 3 (wich find first)
1) gxB-b5xa4 score:+200
2)gxB-e5xf4 score:+200
3)gxB-g5xf4 score:+200
a4xb5... could not be the best move anymore cause gxB was found first because for iterative deepening I choice first the best move of previous depth!!!!

Whith depth=3 the best move is one of this 4 (depends on wich was found first):
1) gxB-b5xa4;f4xe5 score: +300 :D
2) gxB-b5xa4;f4xg5 score: +300 :D
3) gxB-e5xf4;a4xb5 score: +300 :D
4) gxB-g5xf4;a4xb5 score: +300 :D

I hope I did not missed any option that invalidates my reasoning. :roll:

Thanks again and again for your time in case you want to use it for it!! :D
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Is correct this reasoning?

Post by Luis Babboni »

cdani wrote:
Luis Babboni wrote: Question about it thinking in the moves order, the usual way is to make a list of possible moves before each ply further to search?
Is usual to test first alone the possible hash move, and if necessary, follow with at least a partial list of moves, tipically captures ordered by something meaningful, and if none is interesting enough, normal moves. There are a lot ideas and discussions about this, but some are very common.
This means it is needed to have hash tables previous to have quiescense search?
I planed to do first quiescense search but just cause, for my actual understanding and even not knowing yet how to do it, seems simplier.
User avatar
hgm
Posts: 28461
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Is correct this reasoning?

Post by hgm »

Well, without quiescence search there will always be a very large temptation to postpone a favorable capture to just before the horizon. Look to a similar position:

[d]8/8/p4p1k/4p2p/P5n1/3R3P/4P1P1/6K1 w - - 0 1

Here you can gain a Knight, and black can also create an escape through e4 with an attack on the Rook. Difference is that neither white norblack have other captures.

At 1 ply hxN is the best move, and gains +300
At 2 ply hxN is still best, but now only +200 because it is followed by h3xg4
At 3 ply hxN is still only +200, as after h3xg4 there is nothing to capture. But a4-a5 has +300, because black cannot capture anything with his move, and after that you will always capture the Knight, wherever it goes,or even if it stays on g4. You will not see that after hxN it will only be +200 because the Pawn gets recaptured, and you will not see that after e5-e4 gxN will lose you a Rook, and Rd4 will let the Knight escape to e5, and only gain you a Pawn. So it switches to a4-a5 at 3 ply.

Most important way to prevent this is quiescence search. If you always search captures, (as alternative to the static evaluation), it would already see at 1 ply that hxN is only +200, and not +300. And at 3 ply it would see that after e4-e5; hxN black would play exR, which would make a Rook withdrawal the best move ,for a score of 0. So it would continue to prefer immediate captureof the Knight, again for+200.

You don't need a hash table to have quiescence search. It is important that you try the 'best' capture first, though. That is the capture of the most valuable piece. Otherwise you get into situations where both sides spend enormous time on capturing each other's pieces with their Queens, protected or not, before they discover it was all nonsense because they could have captured the opponent's Queen immediately, so that it could not have gone on capturing.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Is correct this reasoning?

Post by Luis Babboni »

Nice!!
Thanks HG!!
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Is correct this reasoning?

Post by cdani »

Luis Babboni wrote:
cdani wrote:
Luis Babboni wrote: Question about it thinking in the moves order, the usual way is to make a list of possible moves before each ply further to search?
Is usual to test first alone the possible hash move, and if necessary, follow with at least a partial list of moves, tipically captures ordered by something meaningful, and if none is interesting enough, normal moves. There are a lot ideas and discussions about this, but some are very common.
This means it is needed to have hash tables previous to have quiescense search?
I planed to do first quiescense search but just cause, for my actual understanding and even not knowing yet how to do it, seems simplier.
I think is more basic to have quiescense search earlier, as the search needs to be stable at first.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Is correct this reasoning?

Post by Luis Babboni »

cdani wrote:
Luis Babboni wrote:
cdani wrote:
Luis Babboni wrote: Question about it thinking in the moves order, the usual way is to make a list of possible moves before each ply further to search?
Is usual to test first alone the possible hash move, and if necessary, follow with at least a partial list of moves, tipically captures ordered by something meaningful, and if none is interesting enough, normal moves. There are a lot ideas and discussions about this, but some are very common.
This means it is needed to have hash tables previous to have quiescense search?
I planed to do first quiescense search but just cause, for my actual understanding and even not knowing yet how to do it, seems simplier.
I think is more basic to have quiescense search earlier, as the search needs to be stable at first.
Soberango is now on 0.07.0 version but 0.08.0 is scheduled for iterative deepening and 0.09.0 for quiescense search. :D