From bad2beec0c9ce2c8bcdf79e534b79e22f725fdcd Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Sat, 12 Apr 2014 14:04:13 -0400 Subject: [PATCH] Search for .so, .dll and .dylib suffixes on the shared library. This should fix #16. --- 2048.py | 14 +++++++++++++- make-msvc.bat | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/2048.py b/2048.py index c5de5ca..15088e1 100644 --- a/2048.py +++ b/2048.py @@ -7,7 +7,16 @@ # Enable multithreading? MULTITHREAD = True -ailib = ctypes.CDLL('bin/2048.so') +for suffix in ['so', 'dll', 'dylib']: + try: + ailib = ctypes.CDLL('bin/2048.' + suffix) + break + except OSError as e: + pass +else: + print "Couldn't load 2048 library bin/2048.{so,dll,dylib}! Make sure to build it first." + exit() + ailib.init_move_tables() ailib.init_score_tables() @@ -82,6 +91,9 @@ def rungame(args): gamectrl = Fast2048Control(ctrl) # gamectrl = Keyboard2048Control(ctrl) + if gamectrl.get_status() == 'ended': + gamectrl.restart_game() + moveno = 0 start = time.time() while 1: diff --git a/make-msvc.bat b/make-msvc.bat index 2dce8a9..f8d305a 100644 --- a/make-msvc.bat +++ b/make-msvc.bat @@ -1,3 +1,3 @@ @mkdir bin cl /W1 /O2 /Gd /MD /D _WINDLL /EHsc /nologo 2048.cpp /Fobin\2048.obj /link /OUT:bin\2048.exe -cl /nologo bin\2048.obj /link /DLL /OUT:bin\2048.so +cl /nologo bin\2048.obj /link /DLL /OUT:bin\2048.dll