Bug 265857

Summary: Solver reports spider is solvable, but no legal move exists
Product: [Applications] kpat Reporter: Jonathan Ryshpan <jonrysh>
Component: solverAssignee: Stephan Kulow <coolo>
Status: RESOLVED FIXED    
Severity: normal CC: jonrysh, kde-games-bugs, shlomif
Priority: NOR    
Version: 3.4   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: This puts spider into a weird state.

Description Jonathan Ryshpan 2011-02-09 06:02:34 UTC
Created attachment 57006 [details]
This puts spider into a weird state.

Version:           3.4 (using KDE 4.5.5) 
OS:                Linux

Starting the game with the attached savedstate.xml produces this situation.

Reproducible: Always

Steps to Reproduce:
Start kpat/spider with the attached savedstate.xml

Actual Results:  
Solver reports spider is solvable, but no legal move exists

Expected Results:  
Either the game is not solvable or a legal move exists.
Comment 1 Stephan Kulow 2011-02-09 10:04:10 UTC
Hah, the solver knows a special move - the 2nd pile has K Q J continueing the sequeunce.

print-layout-begin
Play0: |QS |TS |2S |8S |9S JS 5S 2S 3S QS AS 
Play1: |JS |7S |KS |QS |JS TS 9S 8S 7S 6S 5S 4S 3S 2S AS 
Play2: |JS |8S |KS |5S |5S JS 4S 9S AS 8S 
Play3: |KS |TS |KS |4S |9S AS 8S 7S 6S 5S 
Play4: |8S |2S |4S |6S 4S TS 
Play5: |2S |3S |7S |QS 8S 7S 6S 5S 
Play6: |5S |AS |3S |9S 6S KS 2S 7S 6S 
Play7: |9S |4S |2S |7S AS KS QS JS TS 
Play8: |KS |3S |QS |3S 4S TS 
Play9: |3S |AS |6S |9S QS JS TS 
Deal0: 
Deal1: 
Deal2: 
Deal3: 
Deal4: 
Off: KS 
print-layout-end
moves 1
  move from 1 out (at 1) Prio: -128
Comment 2 Parker Coates 2011-02-09 14:46:21 UTC
Hmm, very similar to bug 260748, but in a completely different part of the code, I assume. :)
Comment 3 Jonathan Ryshpan 2011-02-09 18:51:51 UTC
(In reply to comment #1)
> Hah, the solver knows a special move - the 2nd pile has K Q J continuing the
> sequence.
> ...

Quite right. I missed this move, also the possibility of moving the 7 on the 7th pile to the 3d pile.  Oddly neither of these moves shows up on pressing Hint.  But it doesn't seem possible to go on to win, which the solver message "This game is winnable" says it ought to be.
Comment 4 Shlomi Fish 2011-02-10 19:49:04 UTC
(In reply to comment #0)
> Created an attachment (id=57006) [details]
> This puts spider into a weird state.
> 
> Version:           3.4 (using KDE 4.5.5) 
> OS:                Linux
> 
> Starting the game with the attached savedstate.xml produces this situation.
> 
> Reproducible: Always
> 
> Steps to Reproduce:
> Start kpat/spider with the attached savedstate.xml
> 
> Actual Results:  
> Solver reports spider is solvable, but no legal move exists
> 
> Expected Results:  
> Either the game is not solvable or a legal move exists.

I can reproduce this on kde-4.6.0 on Mandriva Linux Cooker (will become Mandriva 2011.0 soon). It's also in /usr/bin/kpat which is without my downstream patch to add http://fc-solve.berlios.de/ support (which cannot solve Spider presently anyway). As reported, the problem is that the built-in kpat solver reports the game as "winnable" but the demo or hint buttons do not do anything. 

Given some spare cycles, I'll try to investigate it, and prepare a fix, independent of my fc-solve patch.
Comment 5 Stephan Kulow 2011-02-11 09:36:06 UTC
the bug is pretty obvious. Check SpiderSolver::get_possible_moves
and see the 

            for ( int l = 0; l < 13; ++l )
            {
                if ( RANK( W[w][Wlen[w]-l-1] ) != l+1 ||
                     SUIT( W[w][Wlen[w]-l-1] ) != ace_suit )

loop. There is no check if the card is face up.
Comment 6 Parker Coates 2011-04-16 04:47:26 UTC
SVN commit 1228140 by coates:

Make the Spider solver check all cards are face up before moving runs.

This was simply a missing check.

BUG:265857

 M  +2 -1      spidersolver.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1228140
Comment 7 Parker Coates 2011-04-16 04:58:45 UTC
SVN commit 1228141 by coates:

Backport of commit 1228140.

Make the Spider solver check all cards are face up before moving runs.

This was simply a missing check.

CCBUG:265857
FIXED-IN:SC4.6.3


 M  +2 -1      spidersolver.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1228141