25,161
edits
Changes
no edit summary
=Layout=
Assuming a [[Depth#MaxPly|maximum search depth]] of N plies with pre-allocated [[Stack|stacks]], the maximum possible PV-length decreases with increasing distance to root aka ply index during search, and actually needs one move less each ply deeper.
Therefor the triangular structure.
===Size===
The total size of the triangular array in moves can be calculated by the [https://en.wikipedia.org/wiki/Triangular_number Triangular number]:
size = 1+2+3+ ... +(N-1)+N = ½ N(N+1)
===Index===
To calculate the index or offset of a PV into a one-dimensional move array by ply either requires storing incremental offsets
or variable multiplication from scratch:
This index calculation might as well be replaced by a redirection via a small pre-calculated lookup table with N entries of indices, pointers or references, similar to two-dimensional [[Java]] arrays as arrays of arrays with different size <ref>[http://leepoint.net/notes-java/data/arrays/arrays-2D-2.html Java: Two-dimensional arrays as arrays of arrays]</ref> .