-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctypes_test.py
More file actions
68 lines (51 loc) · 2.03 KB
/
ctypes_test.py
File metadata and controls
68 lines (51 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import ctypes
import os
from numpy.ctypeslib import ndpointer
_file = 'testlib1.so'
_path = os.path.join(*(os.path.split(__file__)[:-1] + (_file,)))
_mod = ctypes.cdll.LoadLibrary(_path)
# up_moves = _mod.up_moves
# up_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# up_moves.restype = ctypes.c_uint64
# down_moves = _mod.down_moves
# down_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# down_moves.restype = ctypes.c_uint64
# left_moves = _mod.left_moves
# left_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# left_moves.restype = ctypes.c_uint64
# right_moves = _mod.right_moves
# right_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# right_moves.restype = ctypes.c_uint64
# ur_moves = _mod.ur_moves
# ur_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# ur_moves.restype = ctypes.c_uint64
# ul_moves = _mod.ul_moves
# ul_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# ul_moves.restype = ctypes.c_uint64
# dr_moves = _mod.dr_moves
# dr_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# dr_moves.restype = ctypes.c_uint64
# dl_moves = _mod.dl_moves
# dl_moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
# dl_moves.restype = ctypes.c_uint64
moves = _mod.moves
moves.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
moves.restype = ctypes.c_uint64
board_y = _mod.board_y
board_y.argtype = ctypes.c_uint64
board_y.restype = ctypes.c_int
board_x = _mod.board_x
board_x.argtype = ctypes.c_uint64
board_x.restype = ctypes.c_int
move_player = _mod.move_player
move_player.argtypes = (ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64)
move_player.restype = ctypes.c_uint64
bc = _mod.bitCount
bc.argtype = ctypes.c_uint64
bc.restype = ctypes.c_int
end_of_game = _mod.endofGame
end_of_game.argtypes = (ctypes.c_uint64, ctypes.c_uint64)
end_of_game.restype = ctypes.c_int
do_everything = _mod.doEverything
do_everything.argtypes = (ctypes.c_uint64, ctypes.c_uint64, ctypes.c_int, ctypes.c_bool, ndpointer(ctypes.c_float, flags="C_CONTIGUOUS"),ndpointer(ctypes.c_float, flags="C_CONTIGUOUS"))
do_everything.restype = ctypes.c_uint64