Skip to content

Commit

Permalink
refactor: move model/engine into bot folder
Browse files Browse the repository at this point in the history
  • Loading branch information
latorc committed Apr 19, 2024
1 parent 03ca716 commit 183959d
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions bot/bot_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
from pathlib import Path
import threading
import json
from mjai.engine import get_engine
from common.utils import ModelFileException
from common.mj_helper import MJAI_TYPE
from common.log_helper import LOGGER
try:
import libriichi
except: # pylint: disable=bare-except
except ImportError:
import riichi as libriichi

from .engine import get_engine
from .bot import * # pylint: disable=wildcard-import, unused-wildcard-import


Expand Down Expand Up @@ -61,7 +60,7 @@ def _init_bot_impl(self, mode:GameMode=GameMode.MJ4P):
elif mode == GameMode.MJ3P:
try:
import libriichi3p
from mjai.engine3p import get_engine as get_engine_3p
from bot.engine3p import get_engine as get_engine_3p
engine = get_engine_3p(self.model_files[mode])
self.mjai_bot = libriichi3p.mjai.Bot(engine, self.seat)
except Exception as e:
Expand Down
5 changes: 2 additions & 3 deletions mjai/engine.py → bot/engine.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
""" Mortal Engine"""

""" Mortal Engine for 4p game"""
import torch
import numpy as np
from torch.distributions import Normal, Categorical
from typing import *
from .model import Brain, DQN

class MortalEngine:
def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions mjai/engine3p.py → bot/engine3p.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
""" Mortal engine for 3p game"""
import numpy as np
import torch
from torch.distributions import Normal, Categorical
from .model3p import Brain, DQN

class MortalEngine:
def __init__(
self,
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion mjai/model3p.py → bot/model3p.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Model 3p"""

from functools import partial
from typing import Optional, Tuple, Union
import torch
Expand Down
1 change: 0 additions & 1 deletion liqi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import base64
from enum import Enum
from typing import List, Dict
from pathlib import Path

from google.protobuf.json_format import MessageToDict, ParseDict
import common.utils as utils
Expand Down
Empty file removed mjai/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

Mahjong AI Assistant for Majsoul, based on mjai (Mortal model) bot impelementaion. When you are in a Majsoul game, AI will give you step-by-step guidance. Now supports Majsoul 3-person and 4-person game modes.

<a href="https://github.com/latorc/MahjongCopilot/releases" target="_blank">下载</a> | <a href="https://mjcopilot.com/help" target="_blank">帮助信息</a> | <a href="https://mjcopilot.com" target="_blank">mjcopilot.com</a>
更多信息请访问网站 Please see website for more information
<a href="https://mjcopilot.com/help" target="_blank">帮助信息</a> | <a href="https://mjcopilot.com" target="_blank">https://mjcopilot.com</a>

---

Expand Down

0 comments on commit 183959d

Please sign in to comment.