Expert approach to solve a game

Hello, while in my fifth day of COVID19 reclusion at home I like playing a free little game called Clever Mines and I’d like to know how a q expert would approach this problem:

It has several modes and levels, but Iike playing triangle cells mode and very hard level (no guessing, if you click a cell where there is any mathematical way to hide a mine, you are dead ).

Sometimes I get a  position where I can’t find a way to go ahead, like this one:

Usually I use the MS Paint tool to identify the current unknowns (a to s, 19 unknowns):

And then I use my basic knowledge of q to solve the deadlock:

I start building a table with all the binary combination of my unknowns (here by mistake I used capital letters for the script while in the second picture I used lower case…):

n: 19;
/2 xexp n
/“i”$(2 xexp n);
/table: ( idx:“i”$(2 xexp n));
table: ( idx:til"i"$(2 xexp n));
table:update A:idx mod 2,B:(idx div 2)mod 2,C:(idx div 4)mod 2 from table;
table:update D:(idx div 8)mod 2,E:(idx div 16)mod 2,F:(idx div 32)mod 2 from table;
table:update G:(idx div 64)mod 2,H:(idx div 128)mod 2,I:(idx div 256)mod 2 from table;
table:update J:(idx div 512)mod 2,K:(idx div 1024)mod 2,L:(idx div 2048)mod 2 from table;
table:update M:(idx div 4096)mod 2,N:(idx div 8192)mod 2,O:(idx div 16384)mod 2 from table;
table:update P:(idx div 32768)mod 2,Q:(idx div 65536)mod 2,R:(idx div 131072)mod 2 from table;
table:update S:(idx div 262144)mod 2 from table;

 

Then I add columns to the table with the equations that I can deduce from the second picture:

table:update EQ01:(A+B+C+H+I+J+K)=(4-1) from table;
table:update EQ02:(A+B+C+D+E+I+K)=(4-1) from table;
table:update EQ03:(C+D+E+K)=(4-2) from table;
table:update EQ04:(C+D+E+F)=(4-2) from table;
table:update EQ05:(E+F)=(3-2) from table;
table:update EQ06:(G+H+J+L)=(1) from table;
table:update EQ07:(G+H+I+J+K+L)=(2) from table;
table:update EQ08:(J+K)=(3-2) from table;
table:update EQ09:(J+L+M+N)=(2) from table;
table:update EQ10:(J+K+L+N)=(2) from table;
table:update EQ11:(L+N)=(3-2) from table;
table:update EQ12:(L+M+N+O)=(4-2) from table;
table:update EQ13:(M+N+O+Q)=(4-2) from table;
table:update EQ14:(P+Q+R+S)=(6-4) from table;
table:update EQ15:(Q+R)=(5-4) from table;
table:update EQ16:(R+S)=(2-1) from table;

then I add the inequation with the maximum number of mines still not found: 

table:update EQ17:(A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S)<=8 from table;

Finally I add a column for the solutions and select the rows that comply the equations:

table:update Sol:(EQ01EQ02EQ03EQ04EQ05EQ06EQ07EQ08EQ09EQ10EQ11EQ12EQ13EQ14EQ15EQ16EQ17)=1 from table;
Solutions:select from table where Sol=1

I display Solutions Table:

<font face='"courier' new monospace> </font>

<font face='"courier' new monospace><br></font>



    idx A B C D E F G H I J K L M N O P Q R S EQ01 EQ02 EQ03 EQ04 EQ05 EQ06 EQ07 EQ08 EQ09 EQ10 EQ11 EQ12 EQ13 EQ14 EQ15 EQ16 EQ17 Sol-------------------------------------------------------------------------------------------------------------------------------------189204 0 0 1 0 1 0 0 0 1 1 0 0 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 334885 1 0 1 0 0 1 0 0 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 334886 0 1 1 0 0 1 0 0 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1



    




    Then I check all columns with only one value to eliminate some unknowns:



    




    




    idx A BCDE FGHI J K L M N O P Q R S EQ01 EQ02 EQ03 EQ04 EQ05 EQ06 EQ07 EQ08 EQ09 EQ10 EQ11 EQ12 EQ13 EQ14 EQ15 EQ16 EQ17 Sol-------------------------------------------------------------------------------------------------------------------------------------189204 0 0101 0001 1 0 0 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 334885 1 0100 1000 0 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 334886 0 1100 1000 0 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1



    




    All the solutions show that c cell hides a mine (C=1) and d, g and h cells are empty (D=0, G=0, H=0).



    




    So I mark c cell and click on d, g and h cells in the game:



    




![]("/legacyfs/online/Clever)



    




    And I go ahead until I finish the game:



    




![]("/legacyfs/online/Clever)



    




    




    




    How would you use q to solve this problem?



    




    Cheers



    




    Francisco