All Projects → clarkwkw → mahjong-ai

clarkwkw / mahjong-ai

Licence: other
A program for investigation on deep learning model for Hong Kong Mahjong.

Programming Languages

python
139335 projects - #7 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to mahjong-ai

akochan-reviewer
🔍🀄️ Review mahjong game log with mjai-compatible mahjong AI.
Stars: ✭ 503 (+1995.83%)
Mutual labels:  mahjong
16mj
16 Mahjong
Stars: ✭ 15 (-37.5%)
Mutual labels:  mahjong
MajsoulAI
雀魂/天凤四人麻将AI;目前段位 雀魂雀圣3 天凤8段。
Stars: ✭ 93 (+287.5%)
Mutual labels:  mahjong
tjmj
网页的天津麻将,从 GoogleCode 导入,不活跃
Stars: ✭ 29 (+20.83%)
Mutual labels:  mahjong
pantheon
Primary Pantheon project repository
Stars: ✭ 21 (-12.5%)
Mutual labels:  mahjong
tenhud
HUD for tenhou.net riichi mahjong server. Shows tsumogiri and hidden tiles.
Stars: ✭ 12 (-50%)
Mutual labels:  mahjong
JapaneseMahjong
日本麻将的库,“求向听数”、“判断胡牌”、“牌面拆解”采用查表法。
Stars: ✭ 96 (+300%)
Mutual labels:  mahjong
mahjong soul api
Python wrapper for the Mahjong Soul (Majsoul) Protobuf objects. It allows to use their API.
Stars: ✭ 30 (+25%)
Mutual labels:  mahjong
ChineseOfficialMahjongHelper
国标麻将小助手——包含算番器、线下实麻计分器、番种详细说明、牌理等
Stars: ✭ 82 (+241.67%)
Mutual labels:  mahjong
autotable
An online mahjong table
Stars: ✭ 39 (+62.5%)
Mutual labels:  mahjong
Deep-Learning-Mahjong---
Reinforcement learning (RL) implementation of imperfect information game Mahjong using markov decision processes to predict future game states
Stars: ✭ 45 (+87.5%)
Mutual labels:  mahjong
mah
a html5 mahjong solitaire game
Stars: ✭ 33 (+37.5%)
Mutual labels:  mahjong

About this project

This is a final year project on investigating deep learning models for Hong Kong Mahjong.

The project consists of 2 stages.

In the 1st stage, various models were implemented. These include heuristics based, Monte-Carlo tree search based, Deep Q learning based and Deep policy gradient based models.

In the 2nd stage, the models were benchmarked by making them compete with each other. A Telegram bot was also built to benchmarking against human players.

The reports of the project could be downloaded here:

Dependencies (main module)

  • C++ 11 compiler
  • cython
  • tensorflow (1.8)
  • (optional) pillow

Dependencies (Telegram bot server module)

  • all libraries required in the main module
  • python-telegram-bot
  • pymongo

Environment Setup

  • Install C++ 11 compiler.
  • Install Python dependencies by pip3 install cython tensorflow==1.8 pillow python-telegram-bot pymongo.
  • Issue the command make to compile the C++ scripts for the Monte Carlo Tree Search model.

List of Test Scripts

During the project, different test scripts were coded for experiments. The scripts are located under /test_cases.

In general, to invoke a test script, issue the command python3 test.py [script_name] [..args for the script].

The use of each script could be found here.

Setting Up the Telegram Bot

  1. Retrieve a Telegram Bot token by talking to BotFather in Telegram.
  2. Set up a MongoDB.
  3. Edit /resources/server_settings.json.

 Change mongo_uri according to the host, username and password of the MongoDB.

 Replace the value of tg_bot_token by the token you retrieved from BotFather.

 (Ignore tg_server_address and tg_server_port since by default the bot is in polling mode.)

  1. Start the bot by python3 start_server.py.

Development Documentation

These are the functions of the modules:

Module Name Functions
Game Implements the Hong Kong Mahjong main game logic, such as turn taking and victory condition checking, etc. The module consists of the Game class and the TGGame class. TGGame is rewritten from Game to facilitate pausing and resuming a game.
MLUtils Implements different machine learning models, mainly deep learning models implemented in Tensorflow.
MoveGenerator Acts as an interface between the Player class and the corresponding AI model in MLUtils.
Player Encapsulate the information of a player, including tiles held and discaded tile history.
ScoringRules Implements the score calculation and victory hand detection mechanism.
TGBotServer Implements the communication with Telegram bot users and game state storing.
TGLanguage Wraps the lamguage pack as Python functions for the Telegram bot.
Tile Encapsulates the information of a tile, such as tile symbol and name.

[Outdated, for reference only] For the detail API documentation, please refer to here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].