1
$\begingroup$

This question already has an answer here:

I am doing n-queen implementation with my own algorithm and I get solutions with Number.But,I want to get output with actual chess board.

This is my piece of code.

solutions(* array *)

MatrixForm[solutions]

MatrixForm[{{2,8,9,15},{3,5,12,14}}].

I want to know how to print to combine with GUI chess board by using my solutions array. Number represents positions of chess board. I am new to mathematica. Thanks.😊😊😊


@David Is this code work for dynamic array?My solutions is for the size of n=4 and get 2 solutions.

$\endgroup$

marked as duplicate by Anton Antonov, m_goldberg, José Antonio Díaz Navas, Thies Heidecke, bbgodfrey Jan 11 at 0:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ I actually trouble in plz😞😞😞 $\endgroup$ – Thuriya Thwin Jan 7 at 16:43
  • 1
    $\begingroup$ Related: 164930, 47590 $\endgroup$ – C. E. Jan 7 at 16:56
2
$\begingroup$
Graphics[
 Table[{FaceForm[None], EdgeForm[Black], Rectangle[{1, 1}, {9, 9}], 
   FaceForm[If[OddQ[i + j], White, Black]], 
   Rectangle[{i, j}, {i + 1, j + 1}],
   FaceForm[Red], Disk[{3.5, 4.5}, .5], Disk[{5.5, 7.5}, .5]}, 
   {i, 1, 8, 1}, {j, 1, 8, 1}]
 ]

enter image description here

Your MatrixForm[{{2,8,9,15},{3,5,12,14}}] makes no sense.

$\endgroup$
  • $\begingroup$ Is this code work for dynamic array?My solutions is for the size of n=4 and get 2 solutions. $\endgroup$ – Thuriya Thwin Jan 7 at 17:21
  • $\begingroup$ @ThuriyaThwin have included a dynamic option. Very primitive but will get you started to something mode robust. $\endgroup$ – Jose Enrique Calderon Jan 8 at 12:50
0
$\begingroup$

To do dymanic chess

Manipulate[Graphics[
 Table[{FaceForm[None], EdgeForm[Black], Rectangle[{1, 1}, {9, 9}], 
   FaceForm[If[OddQ[i + j], White, Black]], 
   Rectangle[{i, j}, {i + 1, j + 1}],
   FaceForm[Red], Disk[{4.5+.5*moveX, 4.5+.5*moveY}, .5], Disk[{5.5+.5*move2X, 7.5+.5*move2Y}, .5]}, 
   {i, 1, 8, 1}, {j, 1, 8, 1}]
 ],{moveX,-6,8},{moveY,-6,8},{move2X,-8,6},{move2Y,-12,2}]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.