Help - Simple Fish strategies

Post the puzzle or solving technique that's causing you trouble and someone will help

Help - Simple Fish strategies

Postby rjamil » Thu Nov 12, 2015 4:26 pm

Hi,

I am coding for Simple Fish strategies (i.e., X-Wing, Swordfish and Jellyfish). However, testing below Sudoku grid, taken from here, for X-Wing:
Code: Select all
000000094760910050090002081070050010000709000080031067240100070010090045900000100

After two hidden pairs and one naked pair detected, Sudoku grid look like:
Code: Select all
+-------------------+----------------------+-----------------+
|   1358 235  12358 |    3568   678  35678 |     67   9    4 |
|      7   6     48 |       9     1     48 |     23   5   23 |
|    345   9    345 |    3456   467      2 |     67   8    1 |
+-------------------+----------------------+-----------------+
|    346   7  23469 |    2468     5    468 |  23489   1 2389 |
|  13456 235 123456 |       7  2468      9 |  23458  23  238 |
|     45   8   2459 |      24     3      1 |   2459   6    7 |
+-------------------+----------------------+-----------------+
|      2   4   3568 |       1    68   3568 |    389   7 3689 |
|    368   1   3678 |    2368     9   3678 |    238   4    5 |
|      9  35  35678 |  234568 24678 345678 |      1  23 2368 |
+-------------------+----------------------+-----------------+

In next step, My program detect Row wise Jellyfish for Candidate 2 at r2468c3479. But above mentioned site detect:
Code: Select all
X-Wing
 (Row->Col) 2 taken off r5c2, based on r59c58
 (Row->Col) 2 taken off r5c3, based on r59c58
 (Row->Col) 2 taken off r5c7, based on r59c58
 (Row->Col) 2 taken off r5c9, based on r59c58
 (Row->Col) 2 taken off r9c4, based on r59c58
 (Row->Col) 2 taken off r9c9, based on r59c58

Let me tell you about my simple fish strategy logic. After calculating digit and line (row/column) wise column/row places, search all three simple fish for each tuple combination. The logic used for searching simple fish is same as searching naked/hidden tuple.

Is there anything wrong in my logic?

Note: I skip line (row or column) checking:
For X-wing:
- if bit count of first tuple cell is not equals to 2; or
- if first tuple cell is not equals to second tuple cell
Code: Select all
if (B[k[T[y][0]]] != 2 || k[T[y][0]] != k[T[y][1]])

For Swordfish:
- if bit count of either first, second or third tuple cell is less than 2; or
- if bit count of union of first, second and third cells is greater than 3
Code: Select all
if (B[k[T[y][0]]] < 2 || B[k[T[y][1]]] < 2 || B[k[T[y][2]]] < 2 || B[k[T[y][0]] | k[T[y][1]] | k[T[y][2]]] != 3)

For Jellyfish:
- if bit count of either first, second, third or forth tuple cell is less than 2; or
- if bit count of union of first, second, third and forth cells is greater than 4[code]if (B[k[T[y][0]]] < 2 || B[k[T[y][1]]] < 2 || B[k[T[y][2]]] < 2 || B[k[T[y][3]]] < 2 || B[k[T[y][0]] | k[T[y][1]] | k[T[y][2]] | k[T[y][3]]] != 4)
Also, skip if no elimination occurs.

Waiting for expert support.

R. Jamil
rjamil
 
Posts: 730
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Help - Simple Fish strategies

Postby JasonLion » Thu Nov 12, 2015 6:23 pm

Does your code report the first fish found, or all detected fish?
User avatar
JasonLion
2017 Supporter
 
Posts: 642
Joined: 25 October 2007
Location: Silver Spring, MD, USA

Re: Help - Simple Fish strategies

Postby rjamil » Fri Nov 13, 2015 2:12 am

Hi Jason,

My code report each and every detected move one at a time.

Pseudo code:
Code: Select all
For each digit in 1 to 9
  For each line in row, column
    Backup line wise digit-column bit

    For each X-Wing in line 36 pair
      If bit count of first pair cell is not equals to 2 or first pair cell is not equals to second pair cell then skip

      For each opposite-line in column if line is row; or row if line is column
        If X-Wing candidate not found in opposite-line other unsolved cells then skip

        mark as X-Wing candidate found in line other cells
        Remove X-Wing candidate from line other cells
      Next opposite-line

      If not mark then skip

      Perform next move search

      Restore X-Wing candidate to line other cells
    Next X-Wing

    For each Sword-Fish in line 84 triplet
      do Sword-Fish search as X-Wing
    Next Sword-Fish

    For each Jelly-Fish in line 126 quad
      do Jelly-Fish search as X-Wing
    Next Jelly-Fish

  Next line
Next digit

For your information, this site also detect same Jelly-Fish after Hidden and Naked-pair found if X-Wing, Sword-Fish and X-Cycles unchecked.

R. Jamil
rjamil
 
Posts: 730
Joined: 15 October 2014
Location: Karachi, Pakistan

Postby Pat » Sun Nov 15, 2015 2:27 pm

rjamil wrote:
I am coding for Simple Fish strategies
(i.e., X-Wing, Swordfish and Jellyfish).

testing below Sudoku grid, taken from sudokuwiki, for X-Wing:

    .......9476.91..5..9...2.81.7..5..1....7.9....8..31.6724.1...7..1..9..459.....1..
My program detect Row wise Jellyfish for Candidate 2 at r2468c3479

you worked in rows
going all the way up to Jellyfish
before looking in columns ??

try this order —
    X-wing in rows or columns
    then Swordfish in rows or columns
    etc
User avatar
Pat
 
Posts: 4056
Joined: 18 July 2005

Re: Help - Basic Fish strategies

Postby rjamil » Thu Nov 19, 2015 9:59 pm

Hi Pat,

Pat wrote:you worked in rows
going all the way up to Jellyfish
before looking in columns ??

try this order —
    X-wing in rows or columns
    then Swordfish in rows or columns
    etc

Yes! you are right. I searched in rows first, from X-Wing to Jelly Fish and then in columns.

But, I see there is no significant difference in solution by detecting Jelly Fish first i/o all X-Wing line wise first then Sword Fish line wise and then finally Jelly Fish line wise.

R. Jamil
--------------------------------------------------
If me and you are being chased by a lion,
I don't have to be faster than the lion,
I just have to be faster than you.
rjamil
 
Posts: 730
Joined: 15 October 2014
Location: Karachi, Pakistan


Return to Help with puzzles and solving techniques