Cryolite / kanachan

A Japanese (Riichi) Mahjong AI Framework
285 stars 40 forks source link

An exception in mjai.app. #58

Open constellation39 opened 1 year ago

constellation39 commented 1 year ago

I compiled the mjai.app using the develop branch and deployed it at https://mjai.app/. During one round of execution, I encountered the following error:

Traceback (most recent call last):
  File "/workspace/bot.py", line 12, in <module>
    main()
  File "/workspace/bot.py", line 8, in main
    kanachan.run()
  File "/workspace/_kanachan.py", line 2220, in run
    self.__on_peng(message)
  File "/workspace/_kanachan.py", line 1933, in __on_peng
    raise RuntimeError(peng)
RuntimeError: ('5s', ('5s', '5sr'))

I added the following code to fix the issue:

if consumed == tuple(['5m', '5mr']):
    consumed = tuple(['5mr', '5m'])
elif consumed == tuple(['5p', '5pr']):
    consumed = tuple(['5pr', '5p'])
elif  consumed == tuple(['5s', '5sr']):
    consumed = tuple(['5sr', '5s'])

I'm not sure if I should proceed this way, so I opened up this issue.

shinkuan commented 1 year ago

I think it can be solved also by changing _NUM2PENG values. https://github.com/Cryolite/kanachan/blob/7379538f851879156cd32f2a509a19eec7df9f71/mjai.app/_kanachan.py#L246-L287