Jimboom7 / AlphaJong

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

There is some question about bot's action. #36

Closed dioarame closed 2 years ago

dioarame commented 2 years ago

Thank you for a good project. There is a question during the play of the script, so I inevitably post the question here.

I'm playing scripts on two servers (global, Japan) and occasionally witness the bot making the wrong choice.

Please look at the below, console log from the Edge and MJ Log. At the end of the game, the bot saw another player's discard 4p leach. However, bot was discard 7p instead of 4p in the hand. This resulted in not only being Ron by that player, but also allowing One-shot.

There are questions about the bot's judgment, and I would like to ask if it is possible to improve.

[MJ Log] Round : South 2 https://mahjongsoul.game.yo-star.com/?paipu=jkjomv-1yy5550x-6d42-659a-fhnj-pmfmiosopppz_a830397198_2 image image

[Console Log] userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Waiting for own turn, sleep 1 second. userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 ##### OWN TURN ##### userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Debug String: 6s|345666m334677p33s|||||515z9p199m|5z1m12z9p64z7p|6z21m26z1p7z2p|437z9m45s3m4p|0,0,0,1|4|2|38 userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Current Danger Level: 50 userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Strategy: General userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Would fold this hand below 0.73 safety. userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Tile Priorities: 2userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 7p: Value: <1.629> Efficiency: <2.683> Yaku Open: <1.000> Yaku Closed: <1.000> Dora: <0.000> Waits: <0.736> Safety: 0.94 userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 4p: Value: <1.613> Efficiency: <2.659> Yaku Open: <1.004> Yaku Closed: <1.004> Dora: <0.000> Waits: <0.389> Safety: 1.00 userscript.html?name=AlphaJong.user.js&id=928ad15b-d66b-4a59-97ba-8934f6b56f4d:1161 Discard: 7p

And the bots seem to tend overdo call when it's on the East wind(Oya) especially when there's no Yaku and hand contain 2 tile of W/G/R dragons. It seems to result in the playing in a tough direction, leaving out hand would be vulnerable in defense.

And this is just suggestion for bot's Tenpai situation. How about when bot made Tenpai with high value (ex, over 3 han), not declare leach and waiting tile with Damaten strategy?

Thanks for good project again, I hope my opinion will help bot performance improvement.

Jimboom7 commented 2 years ago

However, bot was discard 7p instead of 4p in the hand.

Thank you for the detailed log. The bot evaluates the efficiency of discarding 7p higher than 4p. It is true that in this case 334p+67p is a better shape than 33p+677p (15 ukeire vs. 13 ukeire and higher chance for ryanmen wait), but that should of course not be more important than the safety of the discard. I need to investigate further why the bot evaluates the difference in safety between 4p and 7p so small.

And the bots seem to tend overdo call when it's on the East wind(Oya) especially when there's no Yaku and hand contain 2 tile of W/G/R dragons.

Yes, I am aware of that problem. The bot loves to call Yakuhai tiles because at the moment it does not care about defense in earlier turns when there is no danger yet. I'm not sure how to improve this, but I will see what I can do.

How about when bot made Tenpai with high value (ex, over 3 han), not declare leach and waiting tile with Damaten strategy?

This is already in the code. But the value is currently set pretty high: At least 5 han (with a bad wait) or 6 han (with a good wait) to go Damaten. I will test if a lower threshold performs better.

dioarame commented 2 years ago

Thanks for tender reply! I don't know much about inner system, but this is my opinion.

First section wrote, the situation is may be analyzed like this as I think, [Our hand is good for waiting, but far from tenpai in early stage. But, other player had already Tenpai and declared Leach - so this situation is very dangerous.] Also, In this step nobody know the value of other player's hand - but with leach, value can be accerlated with Ura Dora.

Someone says Oya's Leach has 9,800 value and other's Leach has 8,000 value average. So, I think in this case the primary action should Defense & caculate our hand's value - Does our hand have enough to value to fight other's leach.

For deaing with this problem, I think how about refer these sources. [http://ara.moo.jp/mjhmr/index.htm] [https://kobalab.net/majiang/dapai.html] Thoes are wriiten with japanese and quite old material, but many people using them when cacluate hand value - after game.

I would like to help these problem, but as I wrote - I don't know much about innter system, especially java - So, It might be not much help.

dioarame commented 2 years ago

Ah, And in the first section discard 4p or 7p problem, I wondered if it was not valid for the bot to recognize not only the efficiency of the handwriting but also the other player's Leach declaration tile as a Suji. However, as players above the intermediate level know, Suji is not 100% safe - just glare Hint -, and even more so, Suji tile of the declaration tile is not safe.

I think there may have been a conflict between the Leach from others and the efficiency of the player's hand. This is thought to be supplemented if there is a process of reviewing the value of the player’s hand. (Betaori if it's cheap, or if it's expensive, throw away safety tiles first?)

Jimboom7 commented 2 years ago

Someone says Oya's Leach has 9,800 value and other's Leach has 8,000 value average. So, I think in this case the primary action should Defense & caculate our hand's value - Does our hand have enough to value to fight other's leach.

The calculation of the expected value of your opponent's hands is now implemented in #46. I would be glad if you try it out and report any bugs or problems you find.

Jimboom7 commented 2 years ago

Version 1.3.0 is now released and should fix most (if not all) problems mentioned in this issue. Like the example from the first post is definitely working now. Your suggestion of calculating the expected value of the opponents hands is also implemented, as well as viewing the tile on the riichi turn as more dangerous.