some problem about threes-ai

#13 · closed · 2 comments

View on GitHub ↗

halfrost

I run web_assistant.py, An error has occurred : "key wasThrown error", I make change according this commit (https://github.com/nneonneo/2048-ai/commit/35d8f9c02c0096e747e94d4d9f6b4f877a4ea1a7), after that, run again. Another error occurre, ``` Traceback (most recent call last): File "web_assistant.py", line 250, in <module> exit(main(sys.argv[1:])) File "web_assistant.py", line 246, in main run_assistant(assistant.gen_board(), assistant.make_move, args.from_start) File "/Users/YDZ/Downloads/threes-ai-python/base_assistant.py", line 99, in run_assistant for newboard, tileset, skip_move in gen_board: File "web_assistant.py", line 160, in gen_board board = map(to_ind, board) File "web_assistant.py", line 18, in to_ind return {0:0, 1:1, 2:2, 3:3, 6:4, 12:5, 24:6, 48:7, 96:8, 192:9, 384:10, 768:11, 1536:12, 3072:13, 6144:14}[val] KeyError: u'A' ``` I add some debug code. I print board: ``` # Convert board values to ranks print "********** board = ",board for i in range(board.__len__()): print board[i] ``` ``` pages = [{u'description': u'', u'title': u'Threes', u'url': u'http://play.threesgame.com/', u'webSocketDebuggerUrl': u'ws://localhost:9222/devtools/page/(B517596AB2C3CFFE3557CB4C6EE5C426)', u'faviconUrl': u'http://play.threesgame.com/favicon.ico', u'type': u'page', u'id': u'(B517596AB2C3CFFE3557CB4C6EE5C426)', u'devtoolsFrontendUrl': u'/devtools/inspector.html?ws=localhost:9222/devtools/page/(B517596AB2C3CFFE3557CB4C6EE5C426)'}] ********** board = Array(16) A r r a y ( 1 6 ) ``` This means board do not read the numbers on the board from web ?

Comments

nneonneo

Oh, that’s weirdly frustrating. Looks like my Javascript code isn’t properly serializing the board. If you are still interested, would you mind submitting a PR to fix this issue?

nneonneo

@halfrost Finally got around to fixing it - I just had to JSONify the array to get the correct behaviour.