I\'m having a huge block trying to understand \"trees\" while making a Tic-Tac-Toe bot. I understand the concept, but I can\'t figure out to implement them.
Can someone
If you want to generate the tree in memory (which is not necessary), perhaps an algorithm like the following could be used (pseudo-code):
GenTree(State s):
T <- empty tree // T is a tree of States
SetRoot(T, s)
ForEach (s' in Successors(s)):
AddChild(T, GenTree(s'))
return T
// Call it
GenTree(currentMove)
where
Successors(s) // returns a list of successor states of s
AddChild(p, n) // adds n to the list of p's children