Questions tagged [mahjong]

15 questions
13
votes
3 answers

Algorithm to find streets and same kind in a hand

This is actually a Mahjong-based question, but a Romme- or even Poker-based background will also easily suffice to understand. In Mahjong 14 tiles (tiles are like cards in Poker) are arranged to 4 sets and a pair. A street ("123") always uses…
mafu
  • 31,798
  • 42
  • 154
  • 247
10
votes
8 answers

Mahjong - Arrange tiles to ensure at least one path to victory, regardless of layout

Regardless of the layout being used for the tiles, is there any good way to divvy out the tiles so that you can guarantee the user that, at the beginning of the game, there exists at least one path to completing the puzzle and winning the…
Buns of Aluminum
  • 2,439
  • 3
  • 26
  • 44
9
votes
6 answers

How do I calculate the shanten number in mahjong?

This is a followup to my earlier question about deciding if a hand is ready. Knowledge of mahjong rules would be excellent, but a poker- or romme-based background is also sufficient to understand this question. In Mahjong 14 tiles (tiles are like …
mafu
  • 31,798
  • 42
  • 154
  • 247
9
votes
6 answers

How can I quickly tell if a list contains only duplicates?

There are multiple related questions, but I'm looking for a solution specific to my case. There is an array of (usually) 14 integers. How can I quickly tell if each int appears exactly twice (i.e. there are 7 pairs)? The value range is from 1 to 35.…
mafu
  • 31,798
  • 42
  • 154
  • 247
7
votes
2 answers

Resources that explain or investigate artificial intelligence (AI) based approaches/strategies to the game of Mahjong

While Mahjong (the actual game, not Mahjong solitare) is fairly simple in terms of basic rules and gameplay, setting objectives for the AI to transition to aim for certain end game goals seems fairly complex. Is anyone aware of any papers,…
tauon
  • 73
  • 6
6
votes
1 answer

How to implement a Mahjong game?

Mahjong is one of the most popular games in Asia (not the solitaire style found in Windows 7). There were plenty of Mahjong games out there including online ones from Yahoo or offline ones back in the DOS days! Just another day I was thinking to…
Henry
  • 32,689
  • 19
  • 120
  • 221
5
votes
7 answers

How can I quickly tell if a list contains a list?

There are multiple related questions, but I'm looking for a solution specific to my case. There is an array of (usually) 14 integers, each in the range of 1 to 34. How can I quickly tell if each int in a specific, static list appears at least once…
mafu
  • 31,798
  • 42
  • 154
  • 247
4
votes
1 answer

Mahjong winning hand algorithm

I'm looking for an algorithm that will determine if the current mahjong hand is a winning one. If you are not familiar with the game, here's the basic idea (simplified): There are three suits of tiles, each containing tiles ranked 1-9. There are…
Igor
  • 2,673
  • 5
  • 33
  • 39
2
votes
0 answers

How to get all the possible winning combination of 17 tile mahjong hand

I'm trying to create a logic to analyze a winning hand in Mahjong and list out all the possible combination of a winning hand. Let me start with some background of the game: In MahJong there are 4 type of tiles - Dots, Bamboos, Characters and…
Osman Wong
  • 170
  • 9
2
votes
1 answer

Identifying a Winning Mahjong Hand

I'm working on trying to identify a winning hand in mahjong, does anyone have any tips or a working formula? The game of mahjong is like gin rummy with 13 cards, sets of 4,3 or flushes of 3. A winning hand includes the stolen or given card, which…
Cyberience
  • 972
  • 10
  • 15
1
vote
4 answers

Mahjong-solitaire solver algorithm, which needs a speed-up

I'm developing a Mahjong-solitaire solver and so far, I'm doing pretty good. However, it is not so fast as I would like it to be so I'm asking for any additional optimization techniques you guys might know of. All the tiles are known from the…
nhaa123
  • 9,570
  • 11
  • 42
  • 63
1
vote
2 answers

What is the best way to store the data for a Mahjong tile set?

I am planning a kids' version of Mahjong Solitaire (starting with just the Turtle board layout and working my way from there). I am trying to wrap my head around how to store the data for each layer of the Turtle layout tileset. See here for an…
TerranRich
  • 1,263
  • 3
  • 20
  • 38
1
vote
3 answers

Please help me speed up this mahjong algorithm

I am writing some mahjong-related functions in JavaScript. Here is what I have below, with code for test cases. Note that mahjong hands are represented by arrays, with: element 0 being the total number of tiles in the hand elements 1 through 34…
Robert L
  • 1,963
  • 2
  • 13
  • 11
1
vote
1 answer

Anyone have the algorithm for determine if a hand of Mahjong game wins or not?

I am reading some introduction of an ancient Chinese game called Mahjong (a bit like poker but far more complicated). I have been spending couple days in writing a program to determine if a given hand is a win hand or not. Do anyone have any idea or…
user1285419
  • 2,183
  • 7
  • 48
  • 70
0
votes
2 answers

iPhone - Need some reference code for card game

I am going to build a card game. Game will be like MahJong. I want some reference code or link to start with. If you have any, then please share it.
Ruchir Shah
  • 898
  • 3
  • 13
  • 31