How to collect PV?

Discussion of chess software programming and technical issues.

Moderator: Ras

benvining
Posts: 42
Joined: Fri May 30, 2025 10:18 pm
Full name: Ben Vining

How to collect PV?

Post by benvining »

I'm working on implementing PV collection during search so that it can be printed in the info output. This is turning out to be a bit tricky to get right: trying to extract it from the transposition table usually results in a too-short PV, and trying to collect it during the search is tricky because you'll get the deepest plies first. Do folks usually collect it during search and reverse the moves array? Am I overthinking this?
Aleks Peshkov
Posts: 918
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: How to collect PV?

Post by Aleks Peshkov »

https://www.chessprogramming.org/Triangular_PV-Table
It is important to know that principal variation is not a list of moves, but different lists of moves for each depth ply during search.
benvining
Posts: 42
Joined: Fri May 30, 2025 10:18 pm
Full name: Ben Vining

Re: How to collect PV?

Post by benvining »

Thanks for the info. I'm looking into the triangular table idea.
Aleks Peshkov
Posts: 918
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: How to collect PV?

Post by Aleks Peshkov »

https://web.archive.org/web/20040620092 ... ing/pv.htm
An alternative data representation of triangular array idea.
Disadvantages:
- Harder to debug.
- Spreads code snippets in several places of the most complex chess code: in the body of search function;
- Needs more stack memory (important only if code portability is an issue);
- Less efficient in garbage collecting languages (minor issue);