mark data type
This commit is contained in:
parent
bd58db47d1
commit
e2a59c827a
|
@ -4,4 +4,4 @@ batch_size = 48
|
||||||
replay_size = 300
|
replay_size = 300
|
||||||
learning_rate = 0.01
|
learning_rate = 0.01
|
||||||
gamma = 0.97
|
gamma = 0.97
|
||||||
train = false
|
train = true
|
||||||
|
|
2
justfile
2
justfile
|
@ -6,6 +6,6 @@ build-cuda:
|
||||||
cd pyr && cargo build --release --features cuda
|
cd pyr && cargo build --release --features cuda
|
||||||
train level:
|
train level:
|
||||||
run level:
|
run level:
|
||||||
python -m mlgame -f 400 -i ./ml/ml_play_pyr_test.py -i ./ml/ml_play_pyr_test.py . --sound off --level {{level}} --game_times 3
|
python -m mlgame -f 400 -i ./ml/ml_play_pyr_test.py -i ./ml/ml_play_manual_2P.py . --sound off --level {{level}} --game_times 3
|
||||||
clean:
|
clean:
|
||||||
rm -r model.bin
|
rm -r model.bin
|
||||||
|
|
|
@ -7,6 +7,7 @@ import pygame
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
|
|
||||||
libpyr = cdll.LoadLibrary("./pyr/target/release/libpyr.so")
|
libpyr = cdll.LoadLibrary("./pyr/target/release/libpyr.so")
|
||||||
|
|
||||||
app_ptr = c_ulonglong(0)
|
app_ptr = c_ulonglong(0)
|
||||||
|
|
||||||
class Overall(Structure):
|
class Overall(Structure):
|
||||||
|
@ -36,6 +37,18 @@ class Food(Structure):
|
||||||
("kind", c_int32),
|
("kind", c_int32),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
libpyr.tick.argtypes = [c_ulonglong, POINTER(Overall), POINTER(Food), c_uint64]
|
||||||
|
libpyr.tick.restype = c_int32
|
||||||
|
|
||||||
|
libpyr.new_app.argtypes = []
|
||||||
|
libpyr.new_app.restype = c_ulonglong
|
||||||
|
|
||||||
|
libpyr.drop_app.argtypes = [c_ulonglong]
|
||||||
|
libpyr.drop_app.restype = None
|
||||||
|
|
||||||
|
libpyr.check_point.argtypes = [c_ulonglong]
|
||||||
|
libpyr.check_point.restype = None
|
||||||
|
|
||||||
def new_app():
|
def new_app():
|
||||||
global app_ptr
|
global app_ptr
|
||||||
app_ptr=c_ulonglong(libpyr.new_app())
|
app_ptr=c_ulonglong(libpyr.new_app())
|
||||||
|
@ -89,7 +102,7 @@ def tick(scene_info: dict):
|
||||||
elif kind=="GARBAGE_3":
|
elif kind=="GARBAGE_3":
|
||||||
foods[i].kind=c_int(6)
|
foods[i].kind=c_int(6)
|
||||||
|
|
||||||
result=libpyr.tick(app_ptr,pointer(overall),pointer(foods),c_uint64(n))
|
result=libpyr.tick(app_ptr,(pointer(overall)),(POINTER(Food))(pointer(foods)),c_uint64(n))
|
||||||
if result==1:
|
if result==1:
|
||||||
return ["UP"]
|
return ["UP"]
|
||||||
if result==2:
|
if result==2:
|
||||||
|
|
|
@ -49,5 +49,5 @@ pub unsafe extern "C" fn new_app() -> *const App {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn drop_app(app: *mut App) {
|
pub unsafe extern "C" fn drop_app(app: *mut App) {
|
||||||
// drop(Box::from_raw(app))
|
drop(Box::from_raw(app))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue