File Fix-the-Forty_Eight-solver-making-illegal-moves.patch of Package kpat4

From 81b9e3eb8deabcd0faae19ca5aaa6f2a65d33365 Mon Sep 17 00:00:00 2001
From: Ian Wadham <iandw.au@gmail.com>
Date: Fri, 24 Jul 2020 23:56:29 +0200
Subject: [PATCH] Fix the Forty & Eight solver making illegal moves

BUGS: 302140
---
 patsolve/fortyeightsolver.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/patsolve/fortyeightsolver.cpp b/patsolve/fortyeightsolver.cpp
index 0e244c28..5678226d 100644
--- a/patsolve/fortyeightsolver.cpp
+++ b/patsolve/fortyeightsolver.cpp
@@ -411,7 +411,14 @@ int FortyeightSolver::get_possible_moves(int *a, int *numout)
         }
         if ( Wlen[w] > 1 && d.freestores )
         {
-            if ( SUIT( *Wp[w] ) == SUIT( W[w][Wlen[w]-2] ) )
+            // Column w has two or more cards and there is at least one empty
+            // column, so we can try for multi-card moves from w to other cols.
+            // This is valid only if ALL the cards to move are of the same
+            // suit and in ascending sequence, starting with the top two cards.
+            const card_t nextw = W[w][Wlen[w]-2];	// Next card after top.
+            const bool possMultiMove = ( SUIT( nextw ) == SUIT( *Wp[w] ) ) &&
+                                       ( ( RANK( nextw ) - RANK( *Wp[w] ) ) == 1 );
+            if ( possMultiMove )
             {
                 //print_layout();
 
-- 
GitLab

openSUSE Build Service is sponsored by