# Course:CPSC312-2017-2PlayerMahjong

## Title

Authors: Crystal Kwong, Aurlin Dhillon

### What is the Problem?

Mahjong is a strategic game where you must take turns drawing and discarding tiles until you have a winning hand. We are attempting to simulate a 2-player version of said game. The rules are fairly simple. There are 72 tiles in the game, and two types of tiles (fire and water). There are fire tiles from 1-9, and 4 of each, and the same for water tiles. Each player has 13 tiles, and take turns drawing cards while simultaneously discarding one of their own. The goal of the game is to make 4 patterns (a straight ([1,2,3 fire], [4,5,6 water], or 3 of a kind ([7,7,7 fire], [2,2,2 water], etc.) and 1 pair.

### What is something extra?

While 2 player mahjong is often played with only 3 of a kind as valid patterns, there is another version that allows straights of size 3. We tried to implement this into our game. This means that there are two valid patterns which are the triplets and the straight. This complicated the logic for the AI as it has to find the optimal pattern combination for the greatest chance of winning. An example is the hand [tile(1, dots, a), tile(1, dots, b), tile(1, dots, c), tile(2, dots, a),tile(3, dots, a),tile(3, dots, b),tile(3, dots, c)] : the optimal pattern combination is 2 triplets (1 and 3) instead of 1 straight (1,2,3).

### What did we learn from doing this?

This part will be filled out after the project is done.

After implementing the logic for 2PlayerMahjong, we have decided that prolog is suitable for this program. We had initial concerns of having prolog not being able to read a straight in your hand which is sorted or being not able to randomize the tiles given once drawed. We realized how difficult some of the logic was in regards to Mahjong as we tackled the project but everything was doable in the end. However, to make the AI be a worthy opponent is a challenging task. There are so many factors to consider and so many different situations that a player must take into account in order to make good decisions, that it would be difficult to code this into our project.

github link is https://github.ubc.ca/aurlin/cs312/tree/master/Desktop