Skip to content

Commit

Permalink
convlog: fix daiminkan in backtrack situation
Browse files Browse the repository at this point in the history
  • Loading branch information
Equim-chan committed Apr 20, 2021
1 parent 7e6937d commit 9a9a4e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions convlog/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ fn tenhou_kyoku_to_mjai_events(
],
});

eprintln!("{}, {}", kyoku.meta.kyoku_num % 4 + 1, kyoku.meta.honba);

let mut actor = oya as usize;
for idx in 0.. {
// Start to process a take event.
Expand Down Expand Up @@ -347,13 +349,15 @@ fn tenhou_kyoku_to_mjai_events(
Some(next) => {
let mut process_dahai = |pai| {
match pai {
// tsumogiri
// tsumogiri or daiminkan
Pai::Unknown => {
eprintln!("{:?}", take_events[actor].peek());
match take_events[actor].peek() {
// Fill the tsumogiri dahai with tsumo pai
// Fill the tsumogiri dahai with tsumo
// pai, see confusing_nakis_3.json
Some(&mjai::Event::Tsumo { pai, .. }) => Some(pai),
// tsumogiri must have a tsumo, not pon or chi
_ => unreachable!(),
// daiminkan, see confusing_nakis_4.json
_ => None,
}
}

Expand Down Expand Up @@ -417,7 +421,7 @@ fn tenhou_kyoku_to_mjai_events(
}
},

// The next discard event is ankan or kakan
// The next discard event is kan
_ => Some(i),
}
}
Expand Down
1 change: 1 addition & 0 deletions convlog/tests/testdata/confusing_nakis_4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"title":["",""],"name":["Aさん","Bさん","Cさん","Dさん"],"rule":{"disp":"鳳南喰赤","aka":1},"log":[[[7,1,1],[25300,27400,30600,15700],[12,44],[],[11,13,13,16,18,18,27,32,37,38,41,46,46],[22,23,24,35,"p464646",19,"18p1818",53,27,12,17],[41,32,27,60,11,60,16,60,60,60,60],[13,15,16,23,23,25,52,31,34,36,37,38,43],[35,16,29,29,44,11,"p161616",44,25,21,45,"252552m25",13],[31,43,60,60,60,60,15,13,44,60,60,0,60],[12,51,16,18,21,22,24,25,33,34,45,45,47],[31,14,38,24,37,11,15,"c131112",17,43,"p454545",31],[60,47,60,21,60,18,60,22,60,60,25,60],[14,17,21,22,26,32,33,36,38,41,42,43,46],[47,36,14,41,18,32,23,34,47,27,39],[43,41,47,60,46,42,32,26,60,60,60],["和了",[5200,0,0,-4200],[0,3,0,"30符3飜3900点","役牌 發(1飜)","ドラ(2飜)"]]]]}
4 changes: 4 additions & 0 deletions convlog/tests/testdata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub const TESTDATA: &[TestCase] = &[
description: "confusing_nakis_3",
data: include_str!("confusing_nakis_3.json"),
},
TestCase {
description: "confusing_nakis_4",
data: include_str!("confusing_nakis_4.json"),
},
TestCase {
description: "double_kakan_then_chankan",
data: include_str!("double_kakan_then_chankan.json"),
Expand Down

0 comments on commit 9a9a4e7

Please sign in to comment.