missing test in tictactoe example
Closed this issue · 3 comments
Hello,
Minor quibble found while testing with very incomplete trees (few training iterations): in step 5, the game loop may seach node for an action when it is None, in the elif branch of
if node is not None and action in node.children:
node = node.children[action]
elif action not in node.children:
node = None
elif test should be node is not None and action not in node.children.
Found out while toying around with short initial trainings combined with in-game training from current state when "falling off" a tree. BTW your library is a great educational resource.
P.G.
Hi Pierre, thanks for pinpointing that out (which I might have missed during my debugging)!
Indeed, if we were to run step 5 with an incomplete tree, there will definitely be an instance where node = None
and trigger an AttributeError
.
In that case, let's roll with this:
if node is not None:
node = node.children[action] if action in node.children else None
I will be adding the code above to the module in the coming days. Cheers!
Feel free to ask questions/point out any bugs in the library; I appreciate it a lot. Will close this issue once I update the library.
Do check the above commit and see if it works. Will be marking this as completed.