There are some algorithms (e.g. the information set graph mentioned in #484) where we want to iterate over the nodes of the game using depth-first traversal.
Implementation a Nodes class as a member of a GameRep. This class should implement an iterator that starts from the root node and successively returns nodes in depth-first traversal order - i.e. the root node first, then the first child of the root node (if any), then the first child of that node (if any), and so on.
Then, in Python, there is currently a class which implements this same idea, including the depth-first search done as a recursive generator. The python implementation can be replaced by a wrapper on the C++ implementation.
Note that the implementation of the iterator in C++ won't be recursive - the most straightforward implementation would be to have a list of iterators over child nodes which functions as a stack.
Tests in Python can be updated accordingly as required.
There are some algorithms (e.g. the information set graph mentioned in #484) where we want to iterate over the nodes of the game using depth-first traversal.
Implementation a
Nodesclass as a member of aGameRep. This class should implement aniteratorthat starts from the root node and successively returns nodes in depth-first traversal order - i.e. the root node first, then the first child of the root node (if any), then the first child of that node (if any), and so on.Then, in Python, there is currently a class which implements this same idea, including the depth-first search done as a recursive generator. The python implementation can be replaced by a wrapper on the C++ implementation.
Note that the implementation of the iterator in C++ won't be recursive - the most straightforward implementation would be to have a list of iterators over child nodes which functions as a stack.
Tests in Python can be updated accordingly as required.