Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop encoder v2 #37

Merged
merged 65 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c0e2cc6
update
Agony5757 Jul 18, 2023
1077669
Update
Agony5757 Jul 19, 2023
387abbb
Update
Agony5757 Jul 19, 2023
8c8b077
Update GameLog
Agony5757 Jul 19, 2023
b25b88f
update
Agony5757 Jul 20, 2023
ec8fc66
update
Agony5757 Jul 20, 2023
cbb9628
update
Agony5757 Jul 20, 2023
8236444
Update
Agony5757 Jul 20, 2023
72ac560
Update
Agony5757 Jul 20, 2023
327ce21
Bug fix.
Agony5757 Jul 20, 2023
7a38c69
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 20, 2023
f8ef10e
Update TrainingDataEncodingV2.h
Agony5757 Jul 20, 2023
17d3508
Initialize TableEncoder
Agony5757 Jul 21, 2023
918faba
Update env_pymahjong.py
Agony5757 Jul 24, 2023
a21f9f7
Update
Agony5757 Jul 25, 2023
50b6b64
Update dora revealing time point.
Agony5757 Jul 25, 2023
30d3de3
Update TrainingDataEncodingV2.h
Agony5757 Jul 25, 2023
cffd60a
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 25, 2023
e747a3a
Mild changes
Agony5757 Jul 25, 2023
7c716b3
Fix utf code.
Agony5757 Jul 25, 2023
b2982ed
Update
Agony5757 Jul 25, 2023
e6e62b3
Add comments
Agony5757 Jul 26, 2023
cd63bb2
Update GameLog.h
Agony5757 Jul 26, 2023
82a0c4b
update comments and polish codes
Agony5757 Jul 26, 2023
8886cd5
Update MahjongPy.cpp
Agony5757 Jul 26, 2023
0c928c8
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 26, 2023
1f5b9c8
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 26, 2023
e70e08b
Create testV2.ipynb
FrostHan Jul 26, 2023
5d13995
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 26, 2023
1aeb4c9
Update testV2.ipynb
FrostHan Jul 27, 2023
f310aca
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 27, 2023
8b5f755
Bug fixed.
Agony5757 Jul 27, 2023
8c12e2b
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 28, 2023
768a53a
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 28, 2023
9b2cbe5
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 28, 2023
f39bd2e
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 28, 2023
6772f32
Update TrainingDataEncodingV2.cpp
Agony5757 Jul 28, 2023
7cfefbe
Bug fix
Agony5757 Aug 24, 2023
f388212
Update TrainingDataEncodingV2.cpp
Agony5757 Sep 1, 2023
dfff69b
Consider the 3ron case. Add extra enum to ResultType
Agony5757 Sep 1, 2023
70fa9c3
Update MahjongPy.cpp
Agony5757 Sep 1, 2023
a8bfb41
Update MahjongPy.cpp
Agony5757 Sep 1, 2023
d1d4f8c
Update MahjongPy.cpp
Agony5757 Sep 1, 2023
0ae0ef4
update
Agony5757 Sep 5, 2023
47e6955
update
Agony5757 Sep 5, 2023
bdec868
Update Table.h
Agony5757 Sep 5, 2023
aa6428b
Now action space can handle red dora!!
FrostHan Sep 6, 2023
18e1d3d
update
Agony5757 Sep 18, 2023
4b870c0
update PassiveTableEncoder
Agony5757 Sep 19, 2023
8e974ac
Update Table.cpp
Agony5757 Nov 8, 2023
aef4e5c
fix bug when initializing table with config, init Table in env with c…
victorywys Jan 12, 2024
af76b86
Merge branch 'Develop-EncoderV2' of github.com:Agony5757/mahjong into…
victorywys Jan 12, 2024
c985b19
Update to 1.0.3.post1
Agony5757 Jan 16, 2024
11ae00e
update
Agony5757 Jan 17, 2024
5e39afc
fix ankan wrong tile after Riichi
FrostHan Jan 17, 2024
b35aac5
Update env_pymahjong.py
FrostHan Jan 17, 2024
2e186cc
default init with kyoutaku=0,honba=0
FrostHan Jan 20, 2024
1f8ad8c
<fix> Adjust the long handler function
Agony5757 Apr 14, 2024
138b59f
<feat> reshuffle_yama to reshuffle during the game
Agony5757 Apr 14, 2024
fe09168
<feat> update reshuffle_yama to python
Agony5757 Apr 14, 2024
91804e9
Fix the chinroutou
Agony5757 Jan 9, 2025
bacf854
Fix all green.
Agony5757 Jan 9, 2025
17dc21d
Update setup.py
Agony5757 Jan 9, 2025
6b97437
Update build-and-test.yml
Agony5757 Jan 9, 2025
33d31db
Update build-and-test.yml
Agony5757 Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:

- name: Build
# Build your program with the given configuration
run: sudo python setup.py install
run: sudo pip install .

- name: Test
run: python -c "import pymahjong as pm;pm.test()" && wget https://github.com/Agony5757/mahjong/releases/download/v1.0.0/paipuxmls.7z && 7z x paipuxmls.7z && python -c "import pymahjong as pm;pm.paipu_replay(mode='debug')"
run: python -c "import pymahjong as pm;pm.test()" && wget https://github.com/Agony5757/mahjong/releases/download/v1.0.4/paipuxmls.7z && 7z x paipuxmls.7z && python -c "import pymahjong as pm;pm.paipu_replay(mode='debug')"

48 changes: 31 additions & 17 deletions Mahjong/Encoding/TrainingDataEncodingV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,26 @@ namespace TrainingDataEncoding {
for (auto& sa : actions) {
switch (sa.action) {
case BaseAction::Discard:
data[int(sa.correspond_tiles[0]->tile)] = 1;
if (sa.correspond_tiles[0]->red_dora)
data[int(sa.correspond_tiles[0]->tile) / 9 + 34] = 1;
else
data[int(sa.correspond_tiles[0]->tile)] = 1;
break;
case BaseAction::AnKan:
data[38] = 1;
data[45] = 1;
break;
case BaseAction::KaKan:
data[40] = 1;
data[47] = 1;
break;
case BaseAction::Riichi:
data[41] = 1;
data[45] = 1;
data[48] = 1;
data[52] = 1;
break;
case BaseAction::Tsumo:
data[43] = 1;
data[50] = 1;
break;
case BaseAction::Kyushukyuhai:
data[44] = 1;
data[51] = 1;
break;
default:
throw runtime_error("Bad SelfAction (while encoding).");
Expand All @@ -285,24 +288,35 @@ namespace TrainingDataEncoding {
for (auto& ra : actions) {
switch (ra.action) {
case BaseAction::Pass:
data[46] = 1;
data[53] = 1;
break;
case BaseAction::Chi:
if (action_tile > ra.correspond_tiles[0]->tile)
if (action_tile < ra.correspond_tiles[1]->tile) data[35] = 1; // middle
else data[36] = 1; // right
else data[34] = 1; // left
if (action_tile > ra.correspond_tiles[0]->tile){
if (action_tile < ra.correspond_tiles[1]->tile){
data[38] = 1; // middle
data[41] = 1; // middle_use_red_dora
}
else{
data[39] = 1; // right
data[42] = 1; // right_use_red_dora
}
}
else{
data[37] = 1; // left
data[40] = 1; // left_use_red_dora
}
break;
case BaseAction::Pon:
data[37] = 1;
data[43] = 1;
data[44] = 1; // use red dora
break;
case BaseAction::Kan:
data[39] = 1;
data[46] = 1;
break;
case BaseAction::Ron:
case BaseAction::ChanKan:
case BaseAction::ChanAnKan:
data[42] = 1;
data[49] = 1;
break;
default:
throw runtime_error("Bad ResponseAction (while encoding).");
Expand Down Expand Up @@ -342,8 +356,8 @@ namespace TrainingDataEncoding {
void encode_actions_vector_riichi_step2(dtype* data)
{
array<dtype, n_actions> buffer = { 0 };
buffer[41] = 1;
buffer[46] = 1;
buffer[48] = 1;
buffer[52] = 1;
memcpy(data, buffer.data(), buffer.size());
}

Expand Down
2 changes: 1 addition & 1 deletion Mahjong/Encoding/TrainingDataEncodingV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace TrainingDataEncoding {
constexpr size_t n_row = size_hand + size_fulu * size_player + size_river * size_player + size_field + size_last + size_action + size_hand * (size_player - 1);
constexpr size_t n_col = n_tile_types;

constexpr size_t n_actions = 47;
constexpr size_t n_actions = 54;

void encode_table(const Table& table, int pid, bool use_oracle, dtype* data);
void encode_table_riichi_step2(const Table& table, BaseTile riichi_tile, dtype* data);
Expand Down
Loading
Loading