Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommendations to Make Mahjong faster #211

Open
jkterry1 opened this issue Apr 11, 2021 · 2 comments
Open

Recommendations to Make Mahjong faster #211

jkterry1 opened this issue Apr 11, 2021 · 2 comments

Comments

@jkterry1
Copy link
Contributor

Hey, the performance of Mahjong is becoming an issue for us, so we're starting to work on it ourselves. Do you have any recommendations on what we should be doing?

@jkterry1
Copy link
Contributor Author

In issue #91 you said you found some redundant logic

@lhenry15
Copy link
Member

Hi,
The current bottleneck is actually on the "judger" class. Because in Mahjong, intensive judgement is needed to define the action space for the players in each round. Based on our evaluation, judging "chow" is now the most inefficient part.
This redundant logic is actually due to the representation of the hand cards. Currently, we are using a string to represent each card, which make it super inefficient when calculating the possible sets in each player's hand. For example, the function "judge_chow" in judger.py, we need to first generate all possible "chow" cases based on one player's card, then we check if each case is consecutive to judge whether the player is able to "chow" in the next round. However, if the card representation can be changed to bag of cards (i.e., n dimensional vector where each dimension representing one kind of card and the value in each dimension representing the number of cards that a player is holding), then judging the "chow" will be simply checking if the card on the table is able to form consecutive non-zero indexes. This way, generating all possible "chow" will be no longer needed, also judging the "pong" and "hu" can also be simplified as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants