smly / mjai.app Goto Github PK
View Code? Open in Web Editor NEWMahjong game simulator for RiichiLab https://mjai.app
Home Page: https://github.com/smly/mjai.app/discussions
License: GNU Affero General Public License v3.0
Mahjong game simulator for RiichiLab https://mjai.app
Home Page: https://github.com/smly/mjai.app/discussions
License: GNU Affero General Public License v3.0
ファイルをアップロードしたあと200が帰ってきていますが、うまく遷移できておらず空白のページに飛んでいます
Describe the bug
Comment of function target_actor_rel()
seems to be wrong.
mjai.app/python/mjai/bot/base.py
Lines 123 to 129 in b53fa40
shimocha should be 1.
Describe the bug
As stated in the title.
Log
The log folder is attached as a .zip file to this bug report.
Expected behavior
The following is an excerpt from mjai_log.json
related to the round where the error occurred. Note that after the log of each dahai by Player 1, I provide the Player 1's hand and the meldings (副露) immediately following the dahai.
{"type":"start_kyoku","bakaze":"E","dora_marker":"6s","kyoku":4,"honba":0,"kyotaku":0,"oya":3,"scores":[12800,52600,22500,12100],"tehais":[["7s","7m","9m","7p","P","8s","4s","8s","F","2m","7s","5pr","7p"],["9m","8p","4p","N","3m","4p","E","8s","2p","S","6m","C","8m"],["5s","5p","W","1m","3s","9s","1p","1s","C","2m"$
{"type":"tsumo","actor":3,"pai":"1s"}
{"type":"dahai","actor":3,"pai":"W","tsumogiri":false}
{"type":"tsumo","actor":0,"pai":"5s"}
{"type":"dahai","actor":0,"pai":"F","tsumogiri":false}
{"type":"tsumo","actor":1,"pai":"4m"}
{"type":"dahai","actor":1,"pai":"N","tsumogiri":false},"3m","4m","6m","8m","9m","2p","4p","4p","8p","8s","E","S","C"
{"type":"tsumo","actor":2,"pai":"W"}
{"type":"dahai","actor":2,"pai":"9p","tsumogiri":false}
{"type":"tsumo","actor":3,"pai":"4m"}
{"type":"dahai","actor":3,"pai":"S","tsumogiri":false}
{"type":"tsumo","actor":0,"pai":"F"}
{"type":"dahai","actor":0,"pai":"F","tsumogiri":true}
{"type":"tsumo","actor":1,"pai":"3p"}
{"type":"dahai","actor":1,"pai":"S","tsumogiri":false},"3m","4m","6m","8m","9m","2p","3p","4p","4p","8p","8s","E","C"
{"type":"tsumo","actor":2,"pai":"3p"}
{"type":"dahai","actor":2,"pai":"C","tsumogiri":false}
{"type":"tsumo","actor":3,"pai":"1p"}
{"type":"dahai","actor":3,"pai":"1m","tsumogiri":false}
{"type":"tsumo","actor":0,"pai":"1p"}
{"type":"dahai","actor":0,"pai":"1p","tsumogiri":true}
{"type":"tsumo","actor":1,"pai":"9m"}
{"type":"dahai","actor":1,"pai":"C","tsumogiri":false},"3m","4m","6m","8m","9m","9m","2p","3p","4p","4p","8p","8s","E"
{"type":"tsumo","actor":2,"pai":"P"}
{"type":"dahai","actor":2,"pai":"P","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"F"}
{"type":"dahai","actor":3,"pai":"F","tsumogiri":true}
{"type":"tsumo","actor":0,"pai":"3p"}
{"type":"dahai","actor":0,"pai":"P","tsumogiri":false}
{"type":"tsumo","actor":1,"pai":"E"}
{"type":"dahai","actor":1,"pai":"8p","tsumogiri":false},"3m","4m","6m","8m","9m","9m","2p","3p","4p","4p","8s","E","E"
{"type":"tsumo","actor":2,"pai":"5m"}
{"type":"dahai","actor":2,"pai":"9s","tsumogiri":false}
{"type":"tsumo","actor":3,"pai":"N"}
{"type":"dahai","actor":3,"pai":"N","tsumogiri":true}
{"type":"tsumo","actor":0,"pai":"7s"}
{"type":"dahai",
[logs.2023-09-02-02-12-52.zip](https://github.com/smly/mjai.app/files/12613400/logs.2023-09-02-02-12-52.zip)
"actor":0,"pai":"2m","tsumogiri":false}
{"type":"tsumo","actor":1,"pai":"7p"}
{"type":"dahai","actor":1,"pai":"7p","tsumogiri":true},"3m","4m","6m","8m","9m","9m","2p","3p","4p","4p","8s","E","E"
{"type":"pon","actor":0,"target":1,"pai":"7p","consumed":["7p","7p"]}
{"type":"dahai","actor":0,"pai":"9m","tsumogiri":false}
{"type":"tsumo","actor":1,"pai":"4s"}
{"type":"dahai","actor":1,"pai":"8s","tsumogiri":false},"3m","4m","6m","8m","9m","9m","2p","3p","4p","4p","4s","E","E"
{"type":"tsumo","actor":2,"pai":"5mr"}
{"type":"dahai","actor":2,"pai":"5s","tsumogiri":false}
{"type":"tsumo","actor":3,"pai":"9p"}
{"type":"dahai","actor":3,"pai":"9p","tsumogiri":true}
{"type":"tsumo","actor":0,"pai":"3m"}
{"type":"dahai","actor":0,"pai":"3m","tsumogiri":true}
{"type":"tsumo","actor":1,"pai":"6s"}
{"type":"dahai","actor":1,"pai":"4p","tsumogiri":false},"3m","4m","6m","8m","9m","9m","2p","3p","4p","4s","6s","E","E"
{"type":"tsumo","actor":2,"pai":"8p"}
{"type":"dahai","actor":2,"pai":"8p","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"2s"}
{"type":"dahai","actor":3,"pai":"1p","tsumogiri":false}
{"type":"tsumo","actor":0,"pai":"1m"}
{"type":"dahai","actor":0,"pai":"7m","tsumogiri":false}
{"type":"chi","actor":1,"target":0,"pai":"7m","consumed":["6m","8m"]}
{"type":"dahai","actor":1,"pai":"6s","tsumogiri":false},"3m","4m","9m","9m","2p","3p","4p","4s","E","E",("7m",("6m","8m"))
{"type":"tsumo","actor":2,"pai":"C"}
{"type":"dahai","actor":2,"pai":"C","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"9s"}
{"type":"dahai","actor":3,"pai":"9s","tsumogiri":true}
{"type":"tsumo","actor":0,"pai":"7m"}
{"type":"dahai","actor":0,"pai":"7m","tsumogiri":true}
{"type":"tsumo","actor":1,"pai":"4m"}
{"type":"dahai","actor":1,"pai":"4s","tsumogiri":false},"3m","4m","4m","9m","9m","2p","3p","4p","E","E",("7m",("6m","8m"))
{"type":"tsumo","actor":2,"pai":"6p"}
{"type":"dahai","actor":2,"pai":"6p","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"P"}
{"type":"dahai","actor":3,"pai":"P","tsumogiri":true}
{"type":"tsumo","actor":0,"pai":"8m"}
{"type":"dahai","actor":0,"pai":"8m","tsumogiri":true}
{"type":"tsumo","actor":1,"pai":"6p"}
{"type":"dahai","actor":1,"pai":"6p","tsumogiri":true},"3m","4m","4m","9m","9m","2p","3p","4p","E","E",("7m",("6m","8m"))
{"type":"tsumo","actor":2,"pai":"7m"}
{"type":"dahai","actor":2,"pai":"7m","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"9s"}
{"type":"dahai","actor":3,"pai":"9s","tsumogiri":true}
{"type":"tsumo","actor":0,"pai":"S"}
{"type":"dahai","actor":0,"pai":"1m","tsumogiri":false}
{"type":"tsumo","actor":1,"pai":"6p"}
{"type":"dahai","actor":1,"pai":"6p","tsumogiri":true},"3m","4m","4m","9m","9m","2p","3p","4p","E","E",("7m",("6m","8m"))
{"type":"tsumo","actor":2,"pai":"P"}
{"type":"dahai","actor":2,"pai":"P","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"5p"}
{"type":"dahai","actor":3,"pai":"1s","tsumogiri":false}
{"type":"tsumo","actor":0,"pai":"5m"}
{"type":"dahai","actor":0,"pai":"5m","tsumogiri":true}
{"type":"chi","actor":1,"target":0,"pai":"5m","consumed":["3m","4m"]}
{"type":"dahai","actor":1,"pai":"4m","tsumogiri":false},"9m","9m","2p","3p","4p","E","E",("7m",("6m","8m")),("5m",("3m","4m"))
{"type":"tsumo","actor":2,"pai":"9m"}
{"type":"dahai","actor":2,"pai":"9m","tsumogiri":true}
{"type":"tsumo","actor":3,"pai":"E"}
{"type":"dahai","actor":3,"pai":"E","tsumogiri":true} ===> player 1 returns {"type": "hora", "actor": 1, "target": 3, "pai": "E"}
{"type":"ryukyoku","deltas":[2000,-8000,2000,4000],"reason":"error"}
{"type":"end_kyoku"}
As described above, Player 1 declares hora
at the end of this round. However, this is flagged as an error. Since 'E' is the round wind, there is a valid hand and 1 han (飜), and it's a legitimate declaration of a win. This win declaration should be correctly accepted.
Describe the bug
mjai.app/python/mjai/bot/base.py
Lines 158 to 166 in b53fa40
Return a empty string when the player's first last action is not tsumo.
https://rowan-jewel-6dd.notion.site/Document-9c36de01d4d243e9a38c6b9e2a81da41
mjxのサンプルを投げたのですがgithubへのリンクが壊れていて、file not foundになっています
また、リンクにあるzipを投げてもcase 4で落ちるのですがこれは意図していますか?
Describe the bug
mjai.app/python/mjai/bot/base.py
Lines 199 to 230 in b53fa40
To Reproduce
Example contidion:
self.player_state.tehai = [
2,1,1,1,4,1,1,1,1,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0
]
self.akas_in_hand = [True, False, False]
Output:
['1m', '1m', '2m', '3m', '4m', '6m', '7m', '8m', '9m', '5mr']
Expected behavior
Should output:
['1m', '1m', '2m', '3m', '4m', '5m', '5m', '5m', '6m', '7m', '8m', '9m', '5mr']
Additional context
A simple fix:
@property
def tehai_mjai(self) -> list[str]:
"""
Player's hand as a list of tile strings in mjai format.
Example:
>>> bot.tehai_mjai
["1m", "2m", "6m", "9m", "1p", "3p", "4p", "3s", "4s", "5s",
"7s", "9s", "5z", "6z"]
"""
zi_map = ["E", "S", "W", "N", "P", "F", "C"]
ms, ps, ss, zis, akas = [], [], [], [], []
tiles = []
for tile_idx, tile_count in enumerate(self.player_state.tehai):
if tile_count and tile_idx == 4 and self.akas_in_hand[0]:
ms += [f"{tile_idx + 1}m"] * (tile_count-1)
akas.append("5mr")
elif tile_count and tile_idx == 4 + 9 and self.akas_in_hand[1]:
ms += [f"{tile_idx + 1}p"] * (tile_count-1)
akas.append("5pr")
elif tile_count and tile_idx == 4 + 18 and self.akas_in_hand[2]:
ms += [f"{tile_idx + 1}s"] * (tile_count-1)
akas.append("5sr")
elif tile_count and tile_idx < 9:
ms += [f"{tile_idx + 1}m"] * tile_count
elif tile_count and tile_idx < 18:
ps += [f"{tile_idx - 9 + 1}p"] * tile_count
elif tile_count and tile_idx < 27:
ss += [f"{tile_idx - 18 + 1}s"] * tile_count
else:
for _ in range(tile_count):
zis.append(zi_map[tile_idx - 27])
tiles = ms + ps + ss + zis + akas
return tiles
Describe the bug
mjai.app/python/mjai/bot/base.py
Lines 429 to 438 in b53fa40
Additional context
A fix:
def action_kakan(self, consumed: list[str]) -> str:
if consumed[0][0] == '5' and consumed[0][1] != 'z':
if any(red in consumed for red in ['5mr', '5pr', '5sr']):
pai = consumed[0][:2]
else:
pai = consumed[0]+'r'
else:
pai = consumed[0]
return json.dumps(
{
"type": "kakan",
"actor": self.player_id,
"pai": pai,
"consumed": consumed, # 3 tiles to be consumed
},
separators=(",", ":"),
)
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
Cargo.toml
anyhow 1
log 0.4
pyo3-log 0.11
once_cell 1
serde_json 1
boomphf 0.6
byteorder 1
rayon 1
ndarray 0.15
numpy 0.21
serde_with 3
rand 0.8
rand_chacha 0.3
flate2 1
sha3 0.10
glob 0.3
derivative 2
ahash 0.8
tinyvec 1
serde 1
mimalloc 0.1
pyo3 0.21
.github/workflows/cargo_test.yml
actions/checkout v4
actions-rs/toolchain v1
actions-rs/cargo v1
actions-rs/cargo v1
actions-rs/cargo v1
.github/workflows/lint.yml
actions/checkout v4
technote-space/get-diff-action v6
actions/setup-python v5
PyO3/maturin-action v1
.github/workflows/pytest.yml
actions/checkout v4
technote-space/get-diff-action v6
actions/setup-python v5
PyO3/maturin-action v1
.github/workflows/release.yml
actions/checkout v4
actions/setup-python v5
PyO3/maturin-action v1
actions/upload-artifact v4
actions/checkout v4
actions/setup-python v5
PyO3/maturin-action v1
actions/upload-artifact v4
actions/checkout v4
actions/setup-python v5
PyO3/maturin-action v1
actions/upload-artifact v4
actions/checkout v4
PyO3/maturin-action v1
actions/upload-artifact v4
actions/download-artifact v4
pyproject.toml
mahjong ~= 1.2.0
pytest ~=8.2.2
maturin >=1.1,<2.0
docker/requirements.txt
torch ==2.2.2
numpy ==1.26.4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.