pasky / pachi

A fairly strong Go/Baduk/Weiqi playing program
http://pachi.or.cz/
GNU General Public License v2.0
505 stars 117 forks source link

Tree garbage collect fix #144

Closed lemonsqueeze closed 3 years ago

lemonsqueeze commented 3 years ago

Fixes issues where most of the tree gets thrown away in case of temp tree overflow during tree gc. Happened with Lizzie when analyzing sometimes for example.

Until now tree_prune() was processing the tree depth-first, but this creates issues in case of overflow: If we run out of nodes deep in the tree we don't have enough for toplevel nodes and most of the tree gets discarded.

-> Prune the tree breadth-first instead so only deep nodes get discarded.

tree_copy() stays depth-first, it can't overflow (simpler/faster). (the old tree_prune() basically)

Other changes: