Ch 13 agent/alphago.py wrong code?
pocca2048 opened this issue · comments
Hi! I am reading your book and I think I found an error in Ch 13.
Why do you reset self.root
here
before referencing it below?
I don't know what was the intention of it but I believe this would be wrong since that will never be executed.
found out this #42
so closing it
This code is wrong either:
if move in self.root.children:
self.root = self.root.children[move]
self.root.parent = None
else:
self.root = AlphaGoNode()
return move
since else is never executed and self.root
cannot reflect opponent's move so that it eventually makes illegal moves.
To solve this, there are two choices:
- reset by
self.root = AlphaGoNode()
no matter what. - make a new function that when opponent makes a move, reflect it on self.root. e.g.,
def reflect_move(self, move):
if move in self.root.children:
self.root = self.root.children[move]
self.root.parent = None
else:
self.root = AlphaGoNode()
Please let me know if I'm wrong.