chuyangliu / snake

Artificial intelligence for the Snake game.
Apache License 2.0
1.65k stars 481 forks source link

Crashes on mac 10.12 sierra #22

Closed nmarkovic04 closed 6 years ago

nmarkovic04 commented 6 years ago

Having issues running it on OS X Sierra:

MacBook-Pro:Snake nikolamarkovic$ python3 run.py Solver: HamiltonSolver Mode: GameMode.NORMAL 2018-04-08 10:31:45.497 Python[9496:4740162] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fbf32ead3c0 2018-04-08 10:31:45.498 Python[9496:4740162] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fbf32ead3c0' First throw call stack: ( 0 CoreFoundation 0x00007fffcdd1d2cb exceptionPreprocess + 171 1 libobjc.A.dylib 0x00007fffe2b3448d objc_exception_throw + 48 2 CoreFoundation 0x00007fffcdd9ef04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00007fffcdc8f755 __forwarding + 1061 4 CoreFoundation 0x00007fffcdc8f2a8 _CF_forwarding_prep_0 + 120 5 Tk 0x0000000109491c02 TkpInit + 471 6 Tk 0x000000010940d2a9 Tk_Init + 1794 7 _tkinter.cpython-36m-darwin.so 0x00000001092e8de3 Tcl_AppInit + 82 8 _tkinter.cpython-36m-darwin.so 0x00000001092e454d _tkinter_create + 1040 9 Python 0x00000001089616c1 _PyCFunction_FastCallDict + 166 10 Python 0x00000001089c600f call_function + 489 11 Python 0x00000001089beecc _PyEval_EvalFrameDefault + 4930 12 Python 0x00000001089c67df _PyEval_EvalCodeWithName + 1829 13 Python 0x00000001089c6ecb fast_function + 227 14 Python 0x00000001089c5fe6 call_function + 448 15 Python 0x00000001089beecc _PyEval_EvalFrameDefault + 4930 16 Python 0x00000001089c67df _PyEval_EvalCodeWithName + 1829 17 Python 0x00000001089c7096 _PyFunction_FastCallDict + 444 18 Python 0x0000000108929ab9 _PyObject_FastCallDict + 196 19 Python 0x0000000108929bdc _PyObject_Call_Prepend + 156 20 Python 0x000000010892993a PyObject_Call + 101 21 Python 0x00000001089748fa slot_tp_init + 57 22 Python 0x0000000108971846 type_call + 184 23 Python 0x0000000108929a84 _PyObject_FastCallDict + 143 24 Python 0x00000001089c5fdf call_function + 441 25 Python 0x00000001089beecc _PyEval_EvalFrameDefault + 4930 26 Python 0x00000001089c67df _PyEval_EvalCodeWithName + 1829 27 Python 0x00000001089c6ecb fast_function + 227 28 Python 0x00000001089c5fe6 call_function + 448 29 Python 0x00000001089beecc _PyEval_EvalFrameDefault + 4930 30 Python 0x00000001089c67df _PyEval_EvalCodeWithName + 1829 31 Python 0x00000001089bdb15 PyEval_EvalCode + 43 32 Python 0x00000001089e525a run_mod + 54 33 Python 0x00000001089e553a PyRun_FileExFlags + 180 34 Python 0x00000001089e4ac7 PyRun_SimpleFileExFlags + 280 35 Python 0x00000001089f8878 Py_Main + 3268 36 Python 0x0000000108917e1d Python + 7709 37 libdyld.dylib 0x00007fffe341a235 start + 1 38 ??? 0x0000000000000002 0x0 + 2 ) libc++abi.dylib: terminating with uncaught exception of type NSException Abort trap: 6

Thoughts?

chuyangliu commented 6 years ago

@nmarkovic04 I am not familiar with OS X but I found this SO question addressing this problem. Would you mind adding the codes below to the beginning of history.py to see if it works?

import os

# Add two lines below
import matplotlib
matplotlib.use("TkAgg")

import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np
nmarkovic04 commented 6 years ago

@chuyangliu Thanks, that worked.