Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ch 13 agent/alphago.py wrong code? #94

Open
pocca2048 opened this issue Aug 16, 2021 · 2 comments
Open

Ch 13 agent/alphago.py wrong code? #94

pocca2048 opened this issue Aug 16, 2021 · 2 comments

Comments

@pocca2048
Copy link

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?

if move in self.root.children: # <2>

I don't know what was the intention of it but I believe this would be wrong since that will never be executed.

@pocca2048
Copy link
Author

found out this #42
so closing it

@pocca2048
Copy link
Author

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:

  1. reset by self.root = AlphaGoNode() no matter what.
  2. 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.

@pocca2048 pocca2048 reopened this Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant