I am implementing a board game engine. To speed up the search I started looking into migrating some parts to Cython. A central (recursive) data structure in the algorithm is a tree node, which points to its parent and its 0..N children. The node has several values, but the one relevant to my question is an np.ndarray
of move probabilities. In essence, I want sth like this:
cdef struct CNNode:
CNNode* parent
list[CNNode*] children
float[:,:,:] probabilities # Could also be np.ndarray, but that also yields an error.
But for probabilities
Cython complains:
C struct/union member cannot be a memory view
I also tried Extension Types, but those apparently don’t support the recursive structure I need.
Is there a way to define the data structure I need in Cython? Thanks!
I really don’t see why extension types wouldn’t work. You would want to use
CNNode
instead ofCNNode*