MahjongRepository / tenhou-python-bot

Bot for tenhou.net riichi mahjong server written in Python
MIT License
201 stars 52 forks source link

Are these lines correct? #20

Closed ycdoit closed 7 years ago

ycdoit commented 7 years ago

I feel there are some lines look incorrect:

First: Should it be self.number_isolated_tiles ^= (1 << k)? Second and Third: Should they be self._run(depth)?

I tried to fix them as above and they passed your unit tests as well. However, I haven't find any negative case that make only original code fail. So, what do you think about above changes?

Nihisil commented 7 years ago

Hi @ycdoit. Thanks for report. Unfortunately I don't have enough time to debug it properly and without real test cases I can't say should be your suggestions applied or not.

So, without hand examples that will fail on the original code and will pass with your changes I prefer to not change anything :)

ycdoit commented 7 years ago

Ok, that's fine.

But I would like to explain my changes.

  1. |= does not un-check the bit, ^= actually can do this.
  2. There is still one tile left when the tile count == 4, and 2 for a pair and 1 for a chow. If you use run(depth+1), you will left one tile unprocessed. It's not easy to test because in most cases, 4 tiles are used for 3 + 1, not for 2 + 1 + 1.