This hand been a really interesting thread to read! Though based on the Rinshan explanation, I feel the developer has watched a tad too much Saki
This bit has be confused though:
or2az wrote: ↑Sun Jul 28, 2019 6:21 pm
"This is a by product of the payments of any valid hand being calculated. This matches the 7 pair shape for a valid hand, but does not satisfy chiitoitsu because of the duplicate pairs. If I were to change this, I would need to change every hand that is yaku nashi, and because of that, I don't think I will."
I've delved in to programming and Mahjong a little bit (eg the wait quiz I made) and either the author is doing something fundamentally wrong, or there is something I'm missing somewhere...
The general logic breakdown of how I feel it should run should be something along the lines of:
* Read tiles and store them in memory - This is the bit done by the camera/image recognition
* Do all calculations as you would normally in a Mahjong video game. - This bit should not be contingent on the previous step. (eg it should be able to work if you manually tell it which tiles are in a hand)
The calculation portion just takes the hand and checks it against all the Yaku (with some minor hierarchy checks so that you don't get say, honitsu and chinitsu for a chinitsu hand). And part of that would be counting the number of each tile (to find pairs and sets), however it won't be counting
as 2 + 2, it would just be a case of tiles[5p] = 4, after which it would move on to the next tile in the hand and result in too few pairs at the end, therefor discounting chiitoi as a valid yaku.
Apologies for the slight rambling post on programming, I just couldn't (and still can't) figure out how they have it set up that a change to the pairs recognition would changed every single yaku nashi hand
If anyone is interested in some of the more technical/coding parts of how computers do Mahjong calculating and can either read Japanese or C-style code (ideally both) there is a great repository of knowledge here:
http://cmj3.web.fc2.com/
EDIT: And I need to finish reading the thread before jumping in and replying, I missed this reply which touches on a few of the things I was trying to say
Barticle wrote: ↑Sun Jul 28, 2019 8:50 pm
Given the way it was presented and the earlier positive replies from a couple of other posters, I really didn't expect there to be such fundamental issues. With the tile recognition, yes - as I noted, that is incredibly difficult to implement - but not with the basic calculation (identifying Yaku and calculating scores).
Yeah, this is basically what I was trying to say in a nutshell. Yes the image recognition is hard, but that should be unrelated to the actual scoring portion.
Barticle wrote: ↑Sun Jul 28, 2019 8:50 pm
To be fair, it is doing a lot of clever stuff and mostly the calculator is doing the right things. However, even if you allow for some issues with the image recognition and user interface, every score calculation needs to be perfect (or otherwise it should be clearly stated for potential users that it's currently a work-in-progress version with flawed functionality). This is especially important for new mahjong players hoping to learn scoring from an app.
Agreed again. The image recognition I expect bugs in, but the scoring really shouldn't be, as there are freely available code samples that can point one in the right direction. And as you said, if it's not working quite right, it should have a disclaimer as such.
Barticle wrote: ↑Sun Jul 28, 2019 8:50 pm
There must be a lot of code behind the scenes, but a seven-pairs hand with two or more identical pairs shouldn't be recognized as complete, even if it doesn't have Chii Toitsu awarded and it'd be a lot of work to fix. Aside from the camera feature, the overall concept must be very similar to other apps (they all perform the same core function after all) but I expect this has been built from scratch - hence the problems!
There might not actually be as much code as you might think, at least outside the image recognition (I have no experience in that area, so I'm not sure about it). The link I posted above has pretty much all you need, and it's only a few hundred lines of code all up.
In the developer's defense, if they have done the scoring side from scratch, then it can be a bit of a pain to get one's head around. But there is also no need to do it from scratch