Riichi Scoring Website / Android Camera App

Japanese Reach Mahjong Rules. Strategy, news, sets - anything!

Moderator: Shirluban

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Riichi Scoring Website / Android Camera App

Post by Barticle » Sat Jul 27, 2019 8:12 pm

A Reddit user posted earlier about their new scoring engine which can be used online here:

https://saki.rinshan.com/

To enter an open set click Chi/Pon first then the first tile of the set.
It says "Add dora" but it's the Dora indicator/s that you enter.
The winning tile should be entered last so it can determine the wait.

It's also available as an Android app which can use your device's camera to detect the tiles in the winning hand!

I'm unable to test that aspect, but it sounds pretty nifty.

https://play.google.com/store/apps/details?id=org.nativescript.RiichiMahjongCalculator

User avatar
or2az
Gold Boarder
Gold Boarder
Posts: 823
Joined: Tue Aug 20, 2013 5:10 pm
Location: USA

Re: Riichi Scoring Website / Android Camera App

Post by or2az » Sat Jul 27, 2019 8:55 pm

I tried the camera option on the Android app.
Took a picture of this hand.
phpv7GnZaPM.jpg
phpv7GnZaPM.jpg (7.87 KiB) Viewed 11332 times
This is what came up. Not quite the same.
phpR0aLgpPM.jpg
phpR0aLgpPM.jpg (30.71 KiB) Viewed 11332 times
phpKvH3DmPM.jpg
phpKvH3DmPM.jpg (33.59 KiB) Viewed 11332 times
I would stick to the original other android calculator, extremely similar, without the camera option, and works perfectly. (see next post)

User avatar
or2az
Gold Boarder
Gold Boarder
Posts: 823
Joined: Tue Aug 20, 2013 5:10 pm
Location: USA

Re: Riichi Scoring Website / Android Camera App

Post by or2az » Sat Jul 27, 2019 9:09 pm

The original one:

http://reachmahjong.com/en/forum/viewto ... tor#p58888

phpoHEEwvPM.jpg
phpoHEEwvPM.jpg (15.8 KiB) Viewed 11331 times
phpTfZT2JPM.jpg
phpTfZT2JPM.jpg (17.74 KiB) Viewed 11331 times
phpGIV7LZPM.jpg
phpGIV7LZPM.jpg (19.19 KiB) Viewed 11331 times

User avatar
or2az
Gold Boarder
Gold Boarder
Posts: 823
Joined: Tue Aug 20, 2013 5:10 pm
Location: USA

Re: Riichi Scoring Website / Android Camera App

Post by or2az » Sat Jul 27, 2019 9:47 pm

I would also mention a couple of other errors I found in that new app.
phpr8SExMPM.jpg
phpr8SExMPM.jpg (14.3 KiB) Viewed 11325 times
RINSHAN KAIHOU is not an automatic yakuman in any ruleset, as far as I know.

phpLMawfAPM.jpg
phpLMawfAPM.jpg (26.59 KiB) Viewed 11325 times
A closed kong of green dragons is 32 fu, not 16.

I wouldn't use this calculator until it is perfected.

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Barticle » Sat Jul 27, 2019 10:10 pm

Hmm, there's certainly plenty of room for improvement in the tile recognition - and some in the user interface and scoring.

I spotted that you can't add two red 5 Dots and it calculates payments for a complete hand with Dora but no Yaku.

I think it should've been presented less as a finished product and more as a public beta test for feedback. I already posted a few suggestions on Reddit regardless.

A further disclaimer in the app store listing says that the software was trained on 2,500 images of a YMI Riichi set and a further 2,000 images from the internet. That it still struggles after that shows how very difficult a technical challenge this is. Not only will tiles be different sizes and orientations, with varying light/shade, but there are so many variations between various tile sets too - marking styles, marking colours (and red fives), front colours, back colours (for concealed quads), Arabic numerals, NEWS and FCP lettering, 萬 vs 万 kanji, blank vs rectangle white dragons, kanji vs actual dragons, etc, etc... The developer is very bold to even attempt this.

The camera feature is potentially a very useful innovation so hopefully, like all software, the new app will continue to improve with future iterations.

So for now yes, it's worth going with an established and proven product instead - or you could buy the YMI tiles! ;)

https://www.ymimports.com/collections/japanese/products/yw-jm001-a

On the calculator website contact page it says "P.S. There is no bug with the Rinshan Kaihou tooltip."?! :shock: (also note the website name)

It does score Rinshan correctly as one Han, but then it doesn't check that you've actually got a quad set either.

I only checked the wait detection earlier (which was fine). It seems that all the Fu values for quad sets need to be doubled.

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Barticle » Sun Jul 28, 2019 12:36 am

I wonder how Saki Rinshan's image recognition would cope with schoolgirls, penguins and tacos...? :D
saki.jpg
saki.jpg (80.83 KiB) Viewed 11309 times

User avatar
or2az
Gold Boarder
Gold Boarder
Posts: 823
Joined: Tue Aug 20, 2013 5:10 pm
Location: USA

Re: Riichi Scoring Website / Android Camera App

Post by or2az » Sun Jul 28, 2019 3:19 am

Yes, this calculator definitely needs work.
A LOT OF WORK!!
Feedback would be a full time job.

How about this yaku?
A mixed straight. Ittsuu in 3 suits.
php3JSfd3PM.jpg
php3JSfd3PM.jpg (28.71 KiB) Viewed 11299 times

A concealed self-draw ? Of what?
Wait! Is this 7 pairs,...... in Chinese mahjong?
php8F35VZPM.jpg
php8F35VZPM.jpg (28.81 KiB) Viewed 11299 times
This app is terrible.
No more time to be wasted.
The End.

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Barticle » Sun Jul 28, 2019 4:19 am

I'd say it needs a little work and a lot of testing. I think these issues would all be simple fixes.

Your time isn't wasted. I'll pass on your feedback with mine for a brighter future!

A mixed straight is valid in some rules (like MCR), but no it shouldn't be here. It's awarding a straight with 123 456 789 in two suits too.

Hmm, I've also noticed it incorrectly gives Chanta without any sequence sets (stacking with Honroutou) and Pinfu with a scoring pair.

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Barticle » Sun Jul 28, 2019 2:46 pm

The developer gave me a comprehensive reply so they're aware of all our issues and suggestions for the calculator.

Apparently the Rinshan text is "more of a strong conviction between me and the people I play mahjong with"!

User avatar
or2az
Gold Boarder
Gold Boarder
Posts: 823
Joined: Tue Aug 20, 2013 5:10 pm
Location: USA

Re: Riichi Scoring Website / Android Camera App

Post by or2az » Sun Jul 28, 2019 6:21 pm

Haha,
I found the page where you posted your constructive comments and the developer thanks you for your keen eye in pointing out the multitude of faults in the calculator.
Also noticed his feedback to your feedback to his feedback (Did I get that right?)
I wasn't too impressed with some of what he was saying, for instance, his reply to
"Five unique pairs and four identical tiles shouldn't allow a Menzen Tsumo win."

"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 don't understand how someone can practically copy another calculator app/website, ruin it in so many ways, and then ask for help to become the first Google search result for "mahjong calculator."

Is it nerve, or just being clueless.
It just doesn't seem right.

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Barticle » Sun Jul 28, 2019 8:50 pm

Thanks are due to your keen eyes :shock: too of course. If credit was ever added, I'd ask that you were mentioned.

It's not uncommon these days for independent developers to make new software available to download at some stage prior to completion. Such an "early access" release allows them to get testing/feedback from users to guide the final stages of building/refining the software and without any significant distribution costs. However it should always be made clear that the product is unfinished.

This calculator was presented on Reddit and the app store as a finished product with no request for suggestions. The only disclaimer is on the app store and that pertains specifically to the tile recognition. There was no mention of the significant bugs or errors in scoring (if these were previously known).

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).

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.

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!

I gave our feedback publically so at least anyone now reading the Reddit thread will be aware.

User avatar
or2az
Gold Boarder
Gold Boarder
Posts: 823
Joined: Tue Aug 20, 2013 5:10 pm
Location: USA

Re: Riichi Scoring Website / Android Camera App

Post by or2az » Sun Jul 28, 2019 9:36 pm

Your detailed explanation is greatly appreciated as it makes me really appreciate the work of the other developer, whose calculator app I have not been able to find a single flaw.

User avatar
Ozball
Expert Reacher
Expert Reacher
Posts: 215
Joined: Wed Nov 06, 2013 2:55 am
Location: Melbourne, Australia

Re: Riichi Scoring Website / Android Camera App

Post by Ozball » Mon Jul 29, 2019 3:49 am

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 :lol:

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 5-dot 5-dot 5-dot 5-dot 5-dot 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 :oops:
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 :?
"Furiten is the most holiest!" - Garthe Nelson

Online Ranks
Tenhou Rating: Ozball - 1608 - 2nd dan


Old Ranks
MFC: オズボール - Seiryu (Blue Dragon) Master
MFC JPML Rank: 3rd kyu
Ron2 Rating: Ozball - 1335 League: Bronze

User avatar
Shirluban
Moderator
Moderator
Posts: 780
Joined: Thu Jan 22, 2009 1:53 pm
Location: Svartalfheim
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Shirluban » Mon Jul 29, 2019 3:12 pm

https://www.reddit.com/r/Mahjong/commen ... alculator/
The payments for any valid hand are calculated, even if the hand is yaku nashi. This is a "feature" that ended up being a "design choice". How the calculator works is that it first tries to assemble a valid hand. A valid hand is 4 sets and a pair, or 7 pairs, or a kokushi musou hand. Then, if a valid hand is found it loops through a list of yaku to see if the hand matches any. At the end the results are displayed, even if there are no valid yaku. My thinking process was that I had no real reason not to cancel the display. The calculator must do all the looping to find a valid hand in the first place, which is where most of the processing time is. So I thought, why not? It might be a bit confusing to newer players, but I think it is an interesting enough "feature" to warrant it.
1) AFAIK, a valid hand is 4 groups and a pair, or 7 different pairs, or kokushi musō.
Not just seven pairs.

2) "Then, if a valid hand is found it loops through a list of yaku to see if the hand matches any. At the end the results are displayed, even if there are no valid yaku."
At this point, the result must shows "invalid hand: no yaku".
There are no reasons to "cancel the display", indeed, but it still has to display the correct score. Where lies the computation time's bottleneck is irrelevant, only user experience matters; and something both confusing to newbies and useless to seasoned players is terrible UX.
Ozball wrote:
Mon Jul 29, 2019 3:49 am
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.
True.
But then it's shouldn't be distributed without intensive testing. Or it should clearly be labelled as a beta version, requesting help to find out the bugs.
The dev is being irresponsible by recommending it "if you are just starting out" while admitting "it might be a bit confusing to newer players".
Cats don't do タンヤオ (tan-yao) but タニャーオ (ta-nya-o).
World Riichi Championship Rules 2022
Comparison of riichi rules around the world

User avatar
Barticle
Platinum Boarder
Platinum Boarder
Posts: 1555
Joined: Thu Apr 30, 2009 12:08 pm
Location: Ipswich, UK (and usually 一向聴地獄)
Contact:

Re: Riichi Scoring Website / Android Camera App

Post by Barticle » Mon Jul 29, 2019 4:43 pm

Shirluban wrote:
Mon Jul 29, 2019 3:12 pm
1) AFAIK, a valid hand is 4 groups and a pair, or 7 different pairs, or kokushi musō.
If the app doesn't detect Shiisan Pūtā, I demand a refund! :x
Ozball wrote:
Mon Jul 29, 2019 3:49 am
[...] 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.
Counting tiles by type sounds like a neat method - there must be exactly two of each tile present (allowing for red fives). The app does check correctly for awarding this Yaku because it doesn't apply Chii Toitsu with identical pairs, but it does still calculate payments with Menzen Tsumo (Tsumo win) or with zero Han (Ron win). I guess it could be using some other method to check for seven pairs as a complete hand, like taking the first tile, finding one match, discounting both, taking the next tile, etc...

The dev could've built the code from scratch for their own satisfaction, for a college project or for their portfolio - and they might simply be unaware of existing available code.

Has anyone else tried the image recognition? I'm curious if it works better with something closer to the YMI Riichi set (darker markings and no numbers/letters in the corners).

Post Reply