[Kde-games-devel] KPat Solver Error

Parker Coates parker.coates at kdemail.net
Sat Jan 16 20:35:02 CET 2010


On Sat, Jan 16, 2010 at 09:51, Julian Helfferich wrote:
> 2010/1/14 John Schneiderman wrote
>> On Thursday 14 January 2010 08:43:54 Parker Coates wrote:
>> > Yes that is the now infamous bug 201073 [1]. If you see this issue
>> > frequently, it would really help us out if you could create a save
>> > file of the game just one step before it makes an illegal move and
>> > attach it to that bug report, we would be most appreciative. If you
>> > could also confirm whether it happens only when playing draw 1 or draw
>> > 3, that would be a big help as well.
>>
>> Parker,
>>
>> I'll certainly do that.
>>
>> John S.
>
> Hello,
>
> i think i found a way to recreate this bug:
>
> 1. Start Kpat, choose Klondike as the game
> 2. Change the game type to draw 1 / draw 3
> 3. Press demo
>
> The problem is, that the solver gets no information about the changing of
> the game type, so it calculates the win moves for draw 1, even if you
> changed the game to draw 3 (or vice versa). The solution is as easy as
> adding one line in the gameTypeChanged slot:
>
> --- klondike.cpp    (revision 1075656)
> +++ klondike.cpp    (working copy)
> @@ -254,6 +254,7 @@
>      if ( allowedToStartNewGame() )
>      {
>          setEasy( options->currentItem() == 0 );
> +    setSolver( new KlondikeSolver( this, pile->draw() ) );
>          startNew( gameNumber() );
>      }
>      else

Thank you very much, Julian! To actually handle all cases properly,
the setSolver line actually has to be in setEasy() which ends up
looking like this:

@@ -285,13 +285,19 @@ void Klondike::setGameOptions( const QString & options )

 void Klondike::setEasy( bool _EasyRules )
 {
-    EasyRules = _EasyRules;
-    pile->setDraws( EasyRules ? 1 : 3 );
-    options->setCurrentItem( EasyRules ? 0 : 1 );
-
-    KConfigGroup cg(KGlobal::config(), settings_group );
-    cg.writeEntry( "KlondikeEasy", EasyRules);
-    cg.sync();
+    if ( _EasyRules != EasyRules )
+    {
+        EasyRules = _EasyRules;
+        options->setCurrentItem( EasyRules ? 0 : 1 );
+
+        int drawNumber = EasyRules ? 1 : 3;
+        pile->setDraws( drawNumber );
+        setSolver( new KlondikeSolver( this, drawNumber ) );
+
+        KConfigGroup cg(KGlobal::config(), settings_group );
+        cg.writeEntry( "KlondikeEasy", EasyRules);
+        cg.sync();
+    }
 }

> I would be glad, if somebody else could recreate the bug by using my short
> instructions, testing the bugfix and (if it's working) commit it to svn.

This does indeed seem to prevent the crash/wrong moves. The difference
doesn't actually seem to be the number of cards dealt, but the fact
that "Draw 1" allows you to pull cards back down from the foundations,
while "Draw 3" does not. I'll commit this and backport to SC4.4.

Thanks again,

Parker


More information about the kde-games-devel mailing list