maxpumperla / deep_learning_and_the_game_of_go

Code and other material for the book "Deep Learning and the Game of Go"

Home Page:https://www.manning.com/books/deep-learning-and-the-game-of-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chapter8:when i running web_mcts.py and play in web,it rasiesd TypeError: 'MCTSAgent' object is not subscriptable

xhw98 opened this issue · comments

commented

but it runed well in web_random.py
lookforward to your reply!

commented

Using TensorFlow backend.

  • Serving Flask app "dlgo.httpfrontend.server" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    [2020-03-28 19:57:25,301] ERROR in app: Exception on /select-move/mcts [POST]
    Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
    File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
    File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
    File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/Users/allen/Downloads/deep_learning_and_the_game_of_go/code/dlgo/httpfrontend/server.py", line 54, in select_move
    bot_agent = bot_map[bot_name]
    TypeError: 'MCTSAgent' object is not subscriptable
    127.0.0.1 - - [28/Mar/2020 19:57:25] "POST /select-move/mcts HTTP/1.1" 500 -

hey, you need to pass a dict, not just a name, e.g.

web_app = get_web_app({'random': random_agent})

your error message indicates that you're trying to call get_web_app(agent) for an instance of MCTSAgent. and just to help you help yourself, something not being subscriptable means a Python object doesn't implement __getitem__ like e.g. dict does. once you know that you'll immediately know that you're not passing the right argument to bot_map[bot_name].

Hope this helps!