Just improved the AI in my Mahjong game a little today. https://play.google.com/store/apps/details?id=com.pvella.mahjong
In simple terms given a hand of 13 tiles, the computer needs to decide what tile to discard which will give it the most chance of winning.
In Hong Kong Style Mahjong I have taken a different approach to traditional games of this type. Usually games will use a Brute Force method of evaluating hands. This involves evaluating every possible hand that could be made and calculating the probability of each hand and aiming for that hand. Some games have even been found to cheat, and actually look at the player's hand. In Hong Kong Style Mahjong, I tried to evaluate a hand, the way I would evaluate a hand if it was me playing. I noticed that I always put different importance on different tiles, a bit like a ranking system, and that depending on the other tiles in a hand, I would put more importance on an individual tile. So I developed a tile ranking system.
A ranking is assigned to each tile in a hand. The ranking is the sole determinant of how important a particular tile is relative to the other tiles in a hand.
When a new tile is drawn from the wall, in effect a hand now has 14 tiles and
needs to discard one. So basically the game needs to decide which tile to discard and basically it works like this:
1) All tiles ranked individually in terms of importance and the least important is discarded. If there are a number of equally ranked tiles then one is removed at random.
2) Tiles are ranked up depending on if there are more of the same tile or they are consecutive
3) Tiles are ranked up by the number of tiles of the same suit
4) Non player or round wins are removed early
5) Honours are ranked high early but removed in middle game if there is only one.
This could obviously be improved but it does play a reasonable game and players have already complained that the game plays too well.
One improvement would be to consider what has been already discarded. Also it could go defensive if it felt a player might be calling.