agony5757 / mahjong Goto Github PK
View Code? Open in Web Editor NEWC++版日麻. Japanese Riichi Mahjong written in C++.
C++版日麻. Japanese Riichi Mahjong written in C++.
错误 LNK2005 main 已经在 CMakeCXXCompilerId.obj 中定义
in >> env.get_aval_next_states(0) out >> (array([], shape=(0, 34, 58), dtype=float64), array([], shape=(0, 29), dtype=float64)) in >> env.t.get_phase() out >> 0
player 0 BaseTile._1p BaseTile._1p player 1 BaseTile._9m BaseTile._7p BaseTile._8p BaseTile._5s BaseTile._9s BaseTile.north BaseTile.haku BaseTile.haku BaseTile.hatsu BaseTile.chu player 2 BaseTile._4m BaseTile._6s BaseTile._7s BaseTile._7s BaseTile._8s BaseTile.east BaseTile.south BaseTile.haku BaseTile.hatsu BaseTile.chu player 3 BaseTile._8m BaseTile._7p BaseTile._5s BaseTile.north BaseTile.hatsu BaseTile.chu BaseTile.chu player 0 [3m]([4m])[5m] [4m][5m*]([6m]) [6p][7p]([8p]) [2s][3s]([4s]) player 1 ([4s])[5s][6s] player 2 [9p]([9p])[9p] player 3 [3s]([3s])[3s] [3p][4p]([5p])
庄家: Player 0 场风: 东 0本场 0立直棒 点数:25000|25000|25000|25000 牌山:2m7m6s0m7p3z5m4s4m3p9p7m4m3s4z5s3m8m9p0p9s6z7s3p1m5z2z4s9p1m8s3z1s2p5z8p8p9s9p4z2s7m3s9m5m4s5s1p8p2p4m3s3m0s6m6p5z7p4p8p5s3m7s7z2z3z6m6s6z7z6s6z8m3p1z8s1z7z1m9s5m1s2z7z8m1s2s6m3p4p8s5p2s5z7p6z4z9m6p7s3s1p5p4s2m8m4m9m2p9s7p9m2z7m7s2s2m2p4p4z8s2m5p3z4p1z6p1m3m1z6s1p1s6m1p6p p0摸牌[3m] p0手切[西] p1摸牌[5s*] p1手切[3s] p3碰[3s]with[3s][3s] p3手切[4m] p0吃[4m]with[3m][5m] p0手切[9p] p2碰[9p]with[9p][9p] p2手切[1s] p3摸牌[6m] p3手切[5m] p0摸牌[6p] p0手切[2m] p1摸牌[白] p1手切[3m] p2摸牌[7p] p2手切[1m] p3摸牌[4p] p3手切[2p] p0摸牌[8p] p0摸切[8p] p1摸牌[5s] p1手切[1m] p2摸牌[3m] p2手切[2p] p3摸牌[7s] p3手切[6m] p0吃[6m]with[4m][5m*] p0手切[4m] p1摸牌[中] p1手切[8m] p2摸牌[南] p2手切[南] p3摸牌[西] p3摸切[西] p0摸牌[6m] p0手切[3p] p1摸牌[6s] p1手切[5s] p2摸牌[发] p2手切[8s] p3摸牌[中] p3手切[9m] p0摸牌[6s] p0手切[6m] p1摸牌[发] p1手切[白] p2摸牌[8m] p2手切[9s] p3摸牌[3p] p3摸切[3p] p0摸牌[东] p0摸切[东] p1摸牌[8s] p1手切[9s] p2摸牌[东] p2手切[8p] p3摸牌[中] p3手切[8p] p0吃[8p]with[6p][7p] p0手切[7m] p1摸牌[1m] p1摸切[1m] p2摸牌[9s] p2摸切[9s] p3摸牌[5m] p3手切[1p] p0摸牌[1s] p0手切[6s] p1摸牌[南] p1摸切[南] p2摸牌[中] p2手切[3m] p3摸牌[8m] p3手切[5m] p0摸牌[1s] p0手切[7m] p1摸牌[2s] p1摸切[2s] p2摸牌[6m] p2手切[8m] p3摸牌[3p] p3手切[7m] p0摸牌[4p] p0手切[4s] p1吃[4s]with[5s][6s] p1手切[5s*] p2摸牌[8s] p2摸切[8s] p3摸牌[5p] p3手切[2s] p0摸牌[2s] p0手切[6s] p1摸牌[白] p1手切[3p] p2摸牌[7p] p2手切[西] p3摸牌[发] p3手切[4s] p0摸牌[北] p0手切[4p] p1摸牌[9m] p1手切[发] p2摸牌[6p] p2手切[6m] p3摸牌[7s] p3手切[7s] p0摸牌[3s] p0手切[北] p1摸牌[1p] p1摸切[1p] p2摸牌[5p] p2手切[4s] p3摸牌[4s] p3手切[5s] p0摸牌[2m] p0摸切[2m] p1摸牌[8m] p1摸切[8m] p2摸牌[4m] p2手切[5p] p3吃[5p]with[3p][4p] p3手切[4s] p0吃[4s]with[2s][3s] 结果:荣和终局 Score: Player 0:0 Player 1:0 Player 2:0 Player 3:0
在测试向听数计算的时候,我发现部分向听数计算可能不正确,例子是245568m245568p77s。normal_round_to_win
算得的向和数为4,实际上为2向听。
查看代码后发现,在计算每个花色的搭子和面子时,由于万饼都是0面3搭或1面0搭,默认都选择了0面3搭最后搭子超载导致多算了一个向听。这里可能需要针对情况枚举或者搜索一下选择哪种。因为不清楚syanten.dat
中这两组数字是怎么算出来的所以不太清楚应该怎么改。。
在python里运行
table.init_game_from_metadata()
会报错
mahjong/Mahjong/ScoreCounter.cpp
Lines 374 to 386 in 88081e3
/* 牌型对/刻/杠,全幺九,不包括字牌,例如999p 1111m */
bool 纯老头(const string &s) {
if (s[2] == 'K' || s[2] == ':' || s[2] == '|') return (s[0] == '1' || s[0] == '9') && s[1] != 'z';
return false;
}
bool 纯绿牌(const string &s) {
const char* green_types[] = {"2sK", "3sK", "4sK", "2sS", "6sK", "8sK", "6zK",
"2s:", "3s:", "4s:", "6s:", "8s:", "6z:", "2s|", "3s|", "4s|", "6s|", "8s|", "6z|", };
return any_of(begin(green_types), end(green_types),
[&s](const char* green) {return tile_group_match(s, green); });
}
环境:ubuntu18.04,python3.10
代码:
import pymahjong
pymahjong.test()
报错:
python test.py
-------------- execption in game 1 -------------------------
'MahjongPyWrapper.Table' object has no attribute 'set_debug_mode'
/home/turk/miniconda3/envs/pymj/lib/python3.10/site-packages/pymahjong/env_pymahjong.py:286: UserWarning: This game has ended, get_curr_player_id return -1 !!
warnings.warn("This game has ended, get_curr_player_id return -1 !!")
----------- current player: -1 -----------------
[Player 0]
点数:25000
自风东
手牌:
牌河:
No立|门清
[Player 1]
点数:25000
自风东
手牌:
牌河:
No立|门清
[Player 2]
点数:25000
自风东
手牌:
牌河:
No立|门清
[Player 3]
点数:25000
自风东
手牌:
牌河:
No立|门清
-------------- replayable log -------------------------------
Traceback (most recent call last):
File "/home/turk/miniconda3/envs/pymj/lib/python3.10/site-packages/pymahjong/test.py", line 18, in test
env.reset(oya=game % 4, game_wind="east", debug_mode=1)
File "/home/turk/miniconda3/envs/pymj/lib/python3.10/site-packages/pymahjong/env_pymahjong.py", line 112, in reset
self.t.set_debug_mode(debug_mode)
AttributeError: 'MahjongPyWrapper.Table' object has no attribute 'set_debug_mode'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/turk/pymahjong_ai/test.py", line 3, in <module>
pymahjong.test()
File "/home/turk/miniconda3/envs/pymj/lib/python3.10/site-packages/pymahjong/test.py", line 56, in test
env.t.print_debug_replay()
AttributeError: 'MahjongPyWrapper.Table' object has no attribute 'print_debug_replay'
论文中的训练代码没有开源是吗?
Small issue. In observation_action_explanation.pdf, only four channels for dora && dora indicators.
Environment: Windows 10, Anaconda, Python 3.9
import pymahjong as pm
env = pm.SingleAgentMahjongEnv()
env.reset()
env.render()
Error message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\py39\lib\site-packages\pymahjong\env_pymahjong.py", line 402, in render
print(self.env.t.players[0].to_string())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 0: invalid start byte
Seems need to fix the function "to_string", also for other objects, such as pm.Table.get_result().to_string()
Hi, I'm interested in the difference between the feature index 4 and 30.
The definitions are
If player 0 has discarded t 1 in this game
If player 0 has discarded >= 1 t
My questions are
I supposed those two are the same but I found some situations where those two are different:
index 4
[False **True** False False False False False False False False False False
False False False False False False True False False False False False
False False False False False False False False False False]
index 30
[False **False** False False False False False False False False False False
False False False False False False True False False False False False
False False False False False False False False False False]
-----------------------------------
[Player 0 (this agent)]
点数:25000
自风东
手牌:1m 1m 2m 1p 2p 3p 4p 6p 7p 8p 0s 6s 7s 1p
牌河:1s1h
No立|门清
...
1 step later
index 4
[False **True** False False False False False False False False False False
False False False False False False True False False False False False
False False False False False False False False False False]
index 30
[False **True** False False False False False False False False False False
False False False False False False True False False False False False
False False False False False False False False False False]
-----------------------------------
[Player 0 (this agent)]
点数:25000
自风东
手牌:1m 1m 1p 1p 2p 3p 4p 6p 7p 8p 0s 6s 7s
牌河:1s1h 2m7h
No立|门清
...
index 4
[False False False False False False False False False True False False
False False False False False False False False False False False False
False False False False False False False **True** False False]
index 30
[False False False False False False False False False True False False
False False False False False False False False False False False False
False False False False False False False **False** False False]
-----------------------------------
[Player 0 (this agent)]
点数:25000
自风东
手牌:3m 4m 5m 7m 8m 2p 3p 4p 1s 2s 3s 8s 5z 9m
牌河:1p1h
No立|门清
...
1 step later
index 4
[False False False True False True False False False True False False
False False False False False False False False False False False False
False False True False False False False **True** False False]
index 30
[False False False True False True False False False True False False
False False False False False False False False False False False False
False False True False False False False **True** False False]
-----------------------------------
[Player 0 (this agent)]
点数:24000
自风东
手牌:3m 4m 5m 7m 8m 9m 2p 3p 4p 1s 2s 3s 8s
牌河:1p1h 5z5hr 9s9r- 4m13r 6m17r
立|门清
...
pycharm会直接输出Process finished with exit code -1073741819 (0xC0000005)这一行,不知道该怎么解决。
作者您好!我在debug代码时,进入一个函数之前,老是进入std vector的alloc等库中。后来发现,函数在传参数的时候,大多数情况都是传的vector,例如Rule.cpp:get听牌()
Table.cpp:game_init_for_replay()
等函数中都出现了这种情况。如果函数只需要读取vector中的内容的话,建议您把参数改成const vector&,这样省去了拷贝,代码运行起来会更快。
庄家: Player 0
场风: 东
0本场 0立直棒
点数:25000|25000|25000|25000
牌山:9p4p8m4s0p6m3p5m8m4m4m9s4s3z9s0m5p8s4z2s2s2m1m7p8p8p3m2m1z1m7s7z4z3m2p6s4p5z2p5p6s9p4s8p6m6p0s4m3m2m7p4p7p6p3z7s9s4z5z3z1s2p8p4m6s6p2p7z1z3s6z5s5s7z1z4p5s3s7s3s9m6m1p5m4z4s9p7s6m5z2z7z2m8s7m9m5m2s3z3p6z9m7m2z3s2z8s7m6z8m1p8s1m3p1z2z1s6z3p1p7p7m1s1s3m5p6s9s9p9m6p1m8m1p5z2s
p0摸牌[7p]
p0手切[6m]
结果:荣和终局
Score:
Player 0:-7000
Player 1:25000
Player 2:25000
Player 3:57000
Player3:|地和|赤宝牌|宝牌||13番30符
need import re in setup.py
它会报类似这样的错:
error: stray ‘\346’ in program
22 | p1���, p1河,
error: expected unqualified-id before ‘:’ token
47 | case Action::荣和:
| ^
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.