File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed
Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -54,3 +54,15 @@ func TestCalculatorShanten(t *testing.T) {
5454 "11m [23m (14m)] " ,
5555 }, tr .records )
5656}
57+
58+ func TestCalculatorShantenTankiBug (t * testing.T ) {
59+ tg := compact .NewTestGenerator (t )
60+ hand := tg .CompactFromString ("23m11112222333z" )
61+ tr := & testResults {}
62+ opts := GetOptions (SetResults (tr ), Opened (0 ))
63+ fm := FilterMelds (hand , CreateAll ())
64+ Calculate (fm , hand , opts )
65+ assert .Equal (t , []string {
66+ "nil [23m (14m) 111z 222z 333z] 12z" ,
67+ }, tr .records )
68+ }
Original file line number Diff line number Diff line change @@ -82,8 +82,22 @@ func (r *calcResult) Record(in *calc.ResultData) {
8282 fullSets := in .Sets > 3
8383
8484 if in .Pair == nil {
85+ var tankiImproves compact.Tiles
8586 for _ , t := range in .Left {
86- improves = improves .Set (t )
87+ tankiImproves = tankiImproves .Set (t )
88+ }
89+ var tankiLocked compact.Tiles
90+ for _ , v := range in .Closed {
91+ if v .Tags ().CheckAny (calc .TagPon ) {
92+ tankiLocked = tankiLocked .Set (v .Tile ())
93+ }
94+ }
95+ tankiLeft := tankiImproves .Sub (tankiLocked )
96+ if tankiLeft .IsEmpty () {
97+ value ++
98+ improves = improves .Merge (compact .AllTiles .Sub (tankiLocked ))
99+ } else {
100+ improves = improves .Merge (tankiLeft )
87101 }
88102 }
89103
Original file line number Diff line number Diff line change @@ -116,13 +116,22 @@ func TestShantenBug1(t *testing.T) {
116116 assert .Equal (t , "1369m179p19s1234567z" , uke .UniqueTiles ().Tiles ().String ())
117117}
118118
119+ func TestShantenBug2 (t * testing.T ) {
120+ tiles := testCompact (t , "23m111122223333z" )
121+ res := Calculate (tiles )
122+ m := res .Total
123+ assert .Equal (t , 2 , m .Value )
124+ uke := m .CalculateUkeIre (compact .NewTotals ().Merge (tiles ))
125+ assert .Equal (t , "123456789m123456789p123456789s4567z" , uke .UniqueTiles ().Tiles ().String ())
126+ }
127+
119128func TestMonocolorBug (t * testing.T ) {
120- tiles := testCompact (t , "1111222235555m " )
129+ tiles := testCompact (t , "1111222235555m1z " )
121130 res := Calculate (tiles )
122131 m := res .Total
123- assert .Equal (t , 1 , m .Value )
132+ assert .Equal (t , 0 , m .Value )
124133 uke := m .CalculateUkeIre (compact .NewTotals ().Merge (tiles ))
125- assert .Equal (t , "3467m " , uke .UniqueTiles ().Tiles ().String ())
134+ assert .Equal (t , "1z " , uke .UniqueTiles ().Tiles ().String ())
126135}
127136
128137func TestImprovesPair (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments