Commit 2d2b1ceb authored by sbl1996@126.com's avatar sbl1996@126.com

Add edopro

parent 16fca7eb
package("edopro-core") package("edopro-core")
set_homepage("https://github.com/edo9300/ygopro-core") -- set_homepage("https://github.com/edo9300/ygopro-core")
set_urls("https://github.com/edo9300/ygopro-core.git") -- set_urls("https://github.com/edo9300/ygopro-core.git")
set_sourcedir(path.join(os.scriptdir(), "edopro-core"))
set_policy("package.install_always", true)
add_deps("lua") add_deps("lua")
...@@ -27,6 +30,12 @@ package("edopro-core") ...@@ -27,6 +30,12 @@ package("edopro-core")
end end
end end
check_and_insert("interpreter.h", 12, "extern \"C\" {")
check_and_insert("interpreter.h", 14, "}")
check_and_insert("interpreter.h", 16, "extern \"C\" {")
check_and_insert("interpreter.h", 19, "}")
local configs = {} local configs = {}
if package:config("shared") then if package:config("shared") then
configs.kind = "shared" configs.kind = "shared"
......
...@@ -99,7 +99,7 @@ if __name__ == "__main__": ...@@ -99,7 +99,7 @@ if __name__ == "__main__":
args.env_threads = min(args.env_threads or args.num_envs, args.num_envs) args.env_threads = min(args.env_threads or args.num_envs, args.num_envs)
args.torch_threads = args.torch_threads or int(os.getenv("OMP_NUM_THREADS", "4")) args.torch_threads = args.torch_threads or int(os.getenv("OMP_NUM_THREADS", "4"))
deck = init_ygopro(args.lang, args.deck, args.code_list_file) deck = init_ygopro(args.env_id, args.lang, args.deck, args.code_list_file)
args.deck1 = args.deck1 or deck args.deck1 = args.deck1 or deck
args.deck2 = args.deck2 or deck args.deck2 = args.deck2 or deck
......
import itertools
from pathlib import Path from pathlib import Path
from ygoenv.ygopro import init_module
def load_deck(fn): def load_deck(fn):
with open(fn) as f: with open(fn) as f:
...@@ -24,7 +21,7 @@ _languages = { ...@@ -24,7 +21,7 @@ _languages = {
"chinese": "zh", "chinese": "zh",
} }
def init_ygopro(lang, deck, code_list_file, preload_tokens=False): def init_ygopro(env_id, lang, deck, code_list_file, preload_tokens=False):
short = _languages[lang] short = _languages[lang]
db_path = Path(get_root_directory(), 'assets', 'locale', short, 'cards.cdb') db_path = Path(get_root_directory(), 'assets', 'locale', short, 'cards.cdb')
deck_fp = Path(deck) deck_fp = Path(deck)
...@@ -41,5 +38,9 @@ def init_ygopro(lang, deck, code_list_file, preload_tokens=False): ...@@ -41,5 +38,9 @@ def init_ygopro(lang, deck, code_list_file, preload_tokens=False):
if not token_deck.exists(): if not token_deck.exists():
raise FileNotFoundError(f"Token deck not found: {token_deck}") raise FileNotFoundError(f"Token deck not found: {token_deck}")
decks["_tokens"] = str(token_deck) decks["_tokens"] = str(token_deck)
if 'YGOPro' in env_id:
from ygoenv.ygopro import init_module
elif 'EDOPro' in env_id:
from ygoenv.edopro import init_module
init_module(str(db_path), code_list_file, decks) init_module(str(db_path), code_list_file, decks)
return deck_name return deck_name
\ No newline at end of file
This diff is collapsed.
...@@ -19,6 +19,12 @@ except ImportError: ...@@ -19,6 +19,12 @@ except ImportError:
pass pass
try:
import ygoenv.edopro.registration # noqa: F401
except ImportError:
pass
try: try:
import ygoenv.dummy.registration # noqa: F401 import ygoenv.dummy.registration # noqa: F401
except ImportError: except ImportError:
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment