Skip to content

Commit

Permalink
Search for .so, .dll and .dylib suffixes on the shared library. This …
Browse files Browse the repository at this point in the history
…should fix #16.
  • Loading branch information
nneonneo committed Apr 12, 2014
1 parent c1172a4 commit bad2bee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion 2048.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion make-msvc.bat
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bad2bee

Please sign in to comment.