Jimboom7 / AlphaJong

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

[Bug report] calculateFu change isClosed value #44

Closed yangruihan closed 2 years ago

yangruihan commented 2 years ago

Overview

At brach experimental-ai-core-rework.

My hand is closed, but AI think is open, so it will accept call by mistack

Play log

I add some log to locate the bug.

-- setData change isCloesd to true

 ##### OWN TURN #####
 Debug String: 8p|45777m123078p22s||222z|111z||3z1s9m7z4s|6437z19p|9m45z8s2m16s|6p6z9m514z9p|0,0,0,0|1|1|45
 Current State: dora:πŸ€ |hand:πŸ€ŠπŸ€‹πŸ€πŸ€πŸ€πŸ€™πŸ€šπŸ€›redπŸ€πŸ€ŸπŸ€ πŸ€‘πŸ€‘|call[0]:|call[1]:πŸ€πŸ€πŸ€|call[2]:πŸ€€πŸ€€πŸ€€|call[3]:|discards[0]:πŸ€‚πŸ€πŸ€πŸ€„πŸ€“|discards[1]:πŸ€…πŸ€ƒπŸ€‚πŸ€„πŸ€™πŸ€‘|discards[2]:πŸ€πŸ€ƒπŸ€†πŸ€—πŸ€ˆπŸ€πŸ€•|discards[3]:πŸ€žπŸ€…πŸ€πŸ€†πŸ€€πŸ€ƒπŸ€‘|riichi:0,0,0,0|seatWind:1|roundWind:1|tilesLeft:45
 Current Danger Level: 7.889356778670876
 Strategy: General
 Consider call on 9p
 -- calculateFu change isclosed to false
 -- calculateFu change isclosed to false
 ... much more calculateFu isclosed to false
 -- calculateFu change isclosed to false
 -- calculateFu change isclosed to false
 Combination found: 7p|8p
 crt isCloesd false
 Call accepted because hand is already open!

I think it should reset isClosed value after calculateFu.

https://github.com/Jimboom7/AlphaJong/blob/1ab5172637c0645d2493450faf051af888dd5910/src/utils.js#L591

yangruihan commented 2 years ago

Need refresh isClosed value after calls[0].pop?

Jimboom7 commented 2 years ago

Thank you, that is indeed a bug. I'm grateful that you are checking the experimental branch, but I have to say it is currently very unstable and probably contains many bugs. I'm surprised it is running at all right now, since I only checked the basic functionality with the testcases. Once it is in a stable state I will create a PR for review, so it's probably better to wait until then.

yangruihan commented 2 years ago

Is there a plan to switch to new algorithm? From my current experience, it performs better than the current algorithm.

ms860309 commented 2 years ago

I also tested the experimental branch and I found that it was broken in 3 players mode. I know there will be many bugs in the beta version, but I just want to say I found this problem

userscript.html?name…f8-bd29206e7ed9:447 
 Uncaught TypeError: view.DesktopMgr.Inst.players[player_correct].hand is not iterable
    at hasPlayerHandChanged (userscript.html?name…bd29206e7ed9:447:64)
    at updateDiscardedTilesSafety (userscript.html?name…bd29206e7ed9:3340:9)
    at setData (userscript.html?name…bd29206e7ed9:3612:3)
    at Proxy.mainOwnTurn (userscript.html?name…bd29206e7ed9:3525:2)
    at it (<anonymous>:14:1074)
    at t.<computed> (<anonymous>:38:422)
    at it (<anonymous>:14:1074)
    at a (<anonymous>:3:446)
    at <anonymous>:4:111
    at <anonymous>:6:169
hasPlayerHandChanged    @   userscript.html?name…f8-bd29206e7ed9:447
updateDiscardedTilesSafety  @   userscript.html?name…8-bd29206e7ed9:3340
setData @   userscript.html?name…8-bd29206e7ed9:3612
mainOwnTurn @   userscript.html?name…8-bd29206e7ed9:3525
it  @   VM4881:14
t.<computed>    @   VM4898:38
it  @   VM4881:14
a   @   VM4898:3
(匿名)    @   VM4898:4
(匿名)    @   VM4881:6
M   @   VM4881:6
yangruihan commented 2 years ago

I would like to ask where is the best place to discuss bugs and suggestions in the experimental branch?