Jimboom7 / AlphaJong

A Mahjong AI for Mahjong Soul
GNU General Public License v3.0
395 stars 56 forks source link

Suggestion for a better algorithm to determine final machi (waiting) tiles #31

Closed osutaiko closed 2 years ago

osutaiko commented 2 years ago

Take the example hand "1155m 1477p 449s 22z + 9s". In this case, the player is in tenpai for chiitoitsu, ready for riichi. Assuming there are the same number of waiting tiles left (unrevealed), as a human, the obvious tile to discard would be 4p since there is a significantly higher chance that opponents would discard 1p (for both safety and hand efficiency). Therefore, whenever there is a situation where the player can choose a single waiting tile (tanki, or kanchan from ryankan) in tenpai, there should be a priority list to determine final machi tiles. (e.g. honor tiles that are only discarded once > 1, 9 > 2, 8 > shouhai honor tiles > 3-7)

Jimboom7 commented 2 years ago

This is already implemented. When calculating the waits the bot checks how useless the tile appears for the opponents. This means not only honors and terminals get a higher wait score, but also tiles around kabe are considered better waits. I tested your example hand and its working perfectly fine there: Hand:1155m1477p4499s22z Tile Priorities: 4p: Value: <2.497> Efficiency: <3.012> Yaku Open: <0.050> Yaku Closed: <2.000> Dora: <0.000> Waits: <5.052> Safety: 1.00 1p: Value: <2.443> Efficiency: <3.012> Yaku Open: <0.050> Yaku Closed: <2.000> Dora: <0.000> Waits: <4.052> Safety: 1.00 This is assuming no discards relevant discards happened yet, so same number of waiting tiles for both 1p and 4p. If this didn't work for you there must have been a reason, e.g. 1p being a very dangerous discard. If you want a higher priority on good waits you can increse the WAIT_VALUE parameter.