Bug 221132 - kmahjongg generates odd number of tiles
Summary: kmahjongg generates odd number of tiles
Status: RESOLVED FIXED
Alias: None
Product: kmahjongg
Classification: Applications
Component: general (show other bugs)
Version: 0.8
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Mauricio Piacentini
URL:
Keywords:
: 251961 261366 277910 332029 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-03 18:17 UTC by Matthias Patz
Modified: 2014-03-13 04:28 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Fixed alien.layout (2.60 KB, text/plain)
2010-09-23 22:20 UTC, Alexey Charkov
Details
Fixed atlantis.layout (2.60 KB, text/plain)
2010-09-23 22:21 UTC, Alexey Charkov
Details
Fixed explosion.layout (2.60 KB, text/plain)
2010-09-23 22:22 UTC, Alexey Charkov
Details
Fixed penta.layout (2.60 KB, text/plain)
2010-09-23 22:23 UTC, Alexey Charkov
Details
Fixed pillars.layout (2.60 KB, text/plain)
2010-09-23 22:24 UTC, Alexey Charkov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Patz 2010-01-03 18:17:35 UTC
Version:           0.8 (using KDE 4.3.1)
OS:                Linux
Installed from:    openSUSE RPMs

kmahjongg used to work properly some weeks ago. now it always* generates an odd number of tiles. the option "generate solvable" does not have any effect on this.






(*) tryed it ~15 times
Comment 1 Thomas Murach 2010-03-02 13:05:14 UTC
I can confirm this bug, but as far as I tested it, this bug only affects the "maps" named 'Castle', 'Explosion', 'Penta' and 'Pillars'. All the other maps from A to S should work fine. At least I never had a problem with one of the others ...

(Version: 0.8, KDE 4.3.5, Opensuse RPM)
Comment 2 W5WMW 2010-05-06 02:51:00 UTC
I ran across this bug independently.  Even when "Generate Solvable Games" is checked, the board "Castle" creates an odd amount of tiles, rendering that board unable to win.

This is a good implementation otherwise, so it just needs a small adjustment on the boards that create situations where you can not win.  Also see bug #156022, which causes an situation where you can't win even with an even amount of tiles.

Thank you.

Kmahjongg version 0.8 on Kubuntu 10.04 LTS
Comment 3 Wolfgang Fritz 2010-07-05 19:52:24 UTC
I would like to confirm the problem with the layouts mentioned above and some others ("alien")

I experienced another problem with layout "explosion": If I select it in the configuration dialog, it is incomplete, saying "Removed 45 / 139" and "Error while creating the game" (messages translated, I have a German version here).

Also, when I create a new "explosion" layout, it sometimes does not show any tiles, in the status bar I get Removed: 0 / 139, Remaining pairs: 13 and also the error message.

I am running Sidux (Debian SID) KDE 4.4.4 . KMahjongg 0.8
Comment 4 Ian Wadham 2010-07-29 14:49:32 UTC
The "Alien" board layout always seems to use an odd number of tiles, making it impossible to solve.  For example I got down to one tile left in game 1,923,144 and the status bar said "Removed 150/151 Combinations left 0" and so I lost.  What a ripoff ... :-)
Comment 5 Ian Wadham 2010-08-05 07:20:56 UTC
I have run a small script to try and identify the layouts that have odd numbers of tiles.  Its intention is to extract and count all the 1's in the layout lines.  There seem to be 6 odd layouts out of 72.  My script and list is:

for f in *.layout; do echo $(cat $f | grep -v '^[a-z#]' | tr -d "\n.a-z234" | wc -c) $f; done | grep -v '[02468] '

151 alien.layout
131 atlantis.layout
157 castle.layout
139 explosion.layout
129 penta.layout
117 pillars.layout

Please can these layouts be fixed or even removed?  Maybe you could add or subtract a tile in each layout.  Possibly some of these layouts got corrupted on editing from v1.0 to v1.1 layout format, so maybe you would need to revive an older revision.  At the worst, you could add a tile in an empty area of the board, which would leave the game-play and difficulty of the layout much the same as it was before, but at least you could win ...
Comment 6 Frederik Schwarzer 2010-09-22 09:33:38 UTC
*** Bug 251961 has been marked as a duplicate of this bug. ***
Comment 7 Frederik Schwarzer 2010-09-22 13:25:22 UTC
I agree with Ian here, that a simple ugly fix like putting another stone somewhere is better than doing nothing. I would like to do this but I do not understand the layout format. Is there a description of it somewhere?
Comment 8 Ian Wadham 2010-09-23 02:39:44 UTC
I do not recommend hand-editing the format and anyway there are two formats: old one for fixed-size board and new one for variable-size.  Have a look at the code Editor.cpp, Editor.h and the commented-out hooks in kmahjongg.cpp.  They should get you going, maybe with a local hack on CMakeLists.txt or even the ui.rc file.  All the best with this ...
Comment 9 Alexey Charkov 2010-09-23 10:20:13 UTC
Guys, please take a closer look at bug 251961, as it contains a fix for castle.layout. I will look into the other ones mentioned here as well. Sorry for not finding this bug and filing a duplicate.

Ian: In fact, I created these by hand in the first place (many were based on those for KDE3 KMahjongg, though), so hand-editing is not that awful :-)
Comment 10 Ian Wadham 2010-09-23 12:29:18 UTC
Editing by hand?  A heroic effort, Alexey, even if you know the format ... :-)

Seriously, it looks as though nobody ever copied and committed your corrected castle.layout ...  Whose job is that?  If you have commit access, Alexey, you could commit corrected layouts yourself.  Otherwise, one of the KDE Games team could.  Just ask.
Comment 11 Alexey Charkov 2010-09-23 22:20:49 UTC
Created attachment 51919 [details]
Fixed alien.layout
Comment 12 Alexey Charkov 2010-09-23 22:21:33 UTC
Created attachment 51920 [details]
Fixed atlantis.layout
Comment 13 Alexey Charkov 2010-09-23 22:22:07 UTC
Created attachment 51921 [details]
Fixed explosion.layout
Comment 14 Alexey Charkov 2010-09-23 22:23:05 UTC
Created attachment 51922 [details]
Fixed penta.layout
Comment 15 Alexey Charkov 2010-09-23 22:24:02 UTC
Created attachment 51923 [details]
Fixed pillars.layout
Comment 16 Alexey Charkov 2010-09-23 22:29:09 UTC
I tried to preserve the visual appearance of the layouts as much as possible, and just added/removed some tiles as applicable. Just put these (and castle.layout from bug 251961) in place of the currently broken ones in your system (/usr/share/apps/kmahjongg/layouts in my case).

Ian: No, I have no commit access. In fact, I've only recently filed that fix, as another user contacted me regarding the breakage. So, I hereby ask for a commit :)
Comment 17 Ian Wadham 2010-09-24 01:09:06 UTC
Mauricio Piacentini is the usual maintainer of KMahjongg, but he is distracted from working by his young son crawling between his legs. OTOH my grandchildren do not get back from holiday till Monday, so I will do the commits for you in the next few days.

If you have any more layouts or levels for KMahjongg or any other game, Alexey, they are always welcome, but it is easiest to contact the game's maintainer or author direct by email and ask how he/she would like to handle them.
Comment 18 Ian Wadham 2010-09-26 01:08:15 UTC
SVN commit 1179575 by ianw:

BUG: 221132 fixed. KMahjongg layouts with odd numbers of tiles, making them impossible to solve, are modified to have even numbers. Many thanks to Alexey Charkov for these modifications.

 M  +2 -2      alien.layout  
 M  +2 -2      atlantis.layout  
 M  +2 -2      castle.layout  
 M  +2 -2      explosion.layout  
 M  +2 -2      penta.layout  
 M  +2 -2      pillars.layout  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1179575
Comment 19 Ian Wadham 2010-09-26 23:39:50 UTC
The fixes should be in KDE 4.5.2 (release due 5 Oct 2010) and also in KDE 4.6.  Thanks again, Alexey.
Comment 20 Frederik Schwarzer 2010-12-27 15:24:57 UTC
*** Bug 261366 has been marked as a duplicate of this bug. ***
Comment 21 Christoph Feck 2011-08-05 19:32:00 UTC
*** Bug 277910 has been marked as a duplicate of this bug. ***
Comment 22 Ian Wadham 2014-03-13 04:28:44 UTC
*** Bug 332029 has been marked as a duplicate of this bug. ***