Jimboom7 / AlphaJong

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

General strategy suggestion #12

Closed YuukyuuKikan closed 2 years ago

YuukyuuKikan commented 2 years ago

Hi, I have tested your script for a while and here's some suggestion on general strategy

-snip- East 3 Turn 7: 788m 4678p 1256s 66z +3z 1s&2s is significantly better than 8m Turn 10: 7m 34678p 12356s 66z +6z? Is it really wise to Pong 6z? East 4 4579m 3356p 779s 44z +5p Turn 6&7: 4 pairs already, 7 pairs could be taken into consideration.

-snip- East 3.0 Turn 8: 11m 2489p 6677s 777z +8p Since the AI is not running 7pairs, it is weird to cut off 7z South 2 Turn 7: 14557789p 34678s + 0p? Pong 5p, No-Yaku except Tanyao.

Thanks for your reading.

Jimboom7 commented 2 years ago

Hi, about the two cases related to 7 pair strategy: The default value for the AI to go for 7 pairs is to have at least 5 pairs in hand. You can change this behaviour by adjusting this variable: var CHIITOITSU = 5; //Number of Pairs in Hand to go for chiitoitsu This hard cutoff is obviously not an optimal strategy, but it's difficult to decide dynamically when to go for 7 pairs.

About the other problems: I'm not an expert Mahjong player, but to me those cases look like reasonable moves by the AI. Maybe not perfect, but imo good enough and not horrible moves that destroy the whole hand.

6ftffyq3 commented 2 years ago

I just reviewed the first log briefly. I want to comment on some other (more problematic) moves by this AI.

East 2: 1 Is it a bug? I think discarding red dora 5m is unreasonable. Discarding normal 5m is already better, and actually 7z should be the best. (5z should be acceptable as well.) 1 Here, I think discarding 5z or 7z should be better.

East 3: 1 If it was a real game with capable players, discarding 5s (dora) here is very dangerous. The (estimated) deal-in probability can be higher than 0.25. It is unreasonable also because after discarding, your hand has only 1 han. Discarding 2p here is much safer and can maintain your tenpai.

There are several other points that I feel not very efficient or safe, but different people may have different ideas. These problems above are for your reference only, which may not be completely correct.

Jimboom7 commented 2 years ago

@6ftffyq3 I created testcases with your first two examples. When I tested your first example the AI discards 6s (because it can lead to a half-flush). 7z and 5z are very close. I think the choice is reasonable and I don't know why it would ever throw the red 5m.

For the second example: In my test the AI discards 5z which is a very good choice.

I don't know why the AI behaves differently for you. Maybe it had problems reading the game data and thought the state of the game is different. Your game-interface doesn't look like mahjong soul, maybe that is related to the problem?

6ftffyq3 commented 2 years ago

@Jimboom7 I am sorry that I was unclear in my previous post. I was just reviewing the first log posted by @YuukyuuKikan. I exported the Mahjong Soul log in another format and replayed using another (lighter) platform, so the moves should be the same as those in the log.

Maybe the original poster did not run your bot in East 2. If it is the case, then the first two problems are irrelevant. I mentioned them because they do seem like bugs (especially for the first one). However, I think the last problem should still be handled by your bot. (The original poster should have enabled your bot in East 3.) The balance of gain and risk is not evaluated reasonably in the last problem.

6ftffyq3 commented 2 years ago

I tested your bot in another game with a normal (at least master level) player and two normal level AI's in Mahjong Soul. (Your bot is running for the whole game.) I have found similar problems in your bot's defense strategy.

1. 1 Defense strategy problem. It is already the last few turns. 1p is dora and none of the other players have discarded 1p yet. Even if there are three 2p's outside, a player may have a pair of 1p's and waiting for another. In addition, the hand worth not much.

2. 2 Still defense strategy problem. The right player's hand patterns probably include half flush. Even though there are three 6p's outside, the right player can still be waiting for 7p (e.g. if the right player has 5p and 6p in hand). The right player's hand at least worth haneman. It can be baiman if there is red dora 5p. Considering the potential loss and the fact that the current hand is worthless, the bot should discard safest 8p, or at least much safer 3s.

3. 3 Efficiency problem (at least in my opinion). There is no 1m left, so discarding 3m will be more efficient.

These are the representative problems (in my opinion) with your bot. The problems may not destroy the hand, but they may affect your bot's performance. Of course, the implementation of solutions may not be easy and can generate new problems if not carefully handled. Therefore, it is for your reference only and you can decide whether considering them is beneficial overall.

YuukyuuKikan commented 2 years ago

Hi all, I have read everything above. The first log was totally performed with script only. I believe that the East 2 -0m cutoff may be from an occasional bug. (Or more likely, network timeout?) The second log was not full-time unattended, I played part of South 2 manually.

Thanks for your discussion.

6ftffyq3 commented 2 years ago

I want to provide another log, which shows problems in general strategy (efficiency and safety considerations). This is a game played by your bot with three human players (all of novice level). Although the bot may be unlucky, there are definitely problems that make the bot lose this game (placed 4th in the end). I will focus on the "all last" round below: (East 4 is the last round in this game)

1. 1 Notice that the bot was 4th place and it was probably the last round. Discarding 8m here is quite unreasonable, because it was less safe than 6p and doing so did not decrease shanten (when it can be decreased). Your bot probably decided not to do toitoi, but it was a critical pattern for the bot to avoid being 4th place. (Is it the case that the bot was defending because the player on the opposite side had many dora tiles? Nevertheless, I think 6p was about the same dangerous as / less dangerous than 8m and the efficiency of 8m was still higher than 6p.)

2. 2 It is probably inappropriate to say so after seeing the results, but the bot's previous wrong move did result in much later tenpai and loss of a chance for yakuman. (I am not a fan of yakuman's because they can be tricky to do, but the bot should have already been in tenpai state for a while with a hand worth at least 5200, probably mangan or haneman. Also, I would not be surprising if a human player achieved yakuman with this hand because it is not so tricky in this case.)

3. 3 Finally, your bot was lucky enough to have a tenpai hand even after wrong moves. Then, why the bot decided to call riichi? The probability of winning is very low for this kind of hand patterns, and the bot loses additional 1000 if it cannot win with this hand (it matters in some cases). Calling riichi decreases your winning probability further. The hand is worth at least mangan (yakuman for tsumo), which is enough for the bot to get 2nd place, so the bot should try to increase probability of winning instead of increasing hand worth. (In my opinion, calling riichi is a bad move.)

6ftffyq3 commented 2 years ago

@YuukyuuKikan I suggest that you do not share your Mahjong Soul log directly by links, because the official supervisors can find out your account information even if it is anonymized. (Actually, everyone is able to get your account information by your log without too much effort.) Since your logs are associated with bot use, someone can technically report you and you may get your account banned (if it is not a friendly match; I am referring to your second log). It should be fine as long as you do not always use bots, but sharing the logs here directly is providing evidence.

Jimboom7 commented 2 years ago

Hi, I just published v1.1.0 of the AI. I can't confidently talk about all the problems mentioned here, but most of them should be fixed. The AI should make better decisions in general, both offense and defense, so I'm closing this issue for now.