The Eight Queens Puzzle Demonstration

The Eight Queens Puzzle Demonstration
Loading the math board and drawing, please wait…
2020-12-31 12:13
The Eight Queens Puzzle is a classic problem in combinatorial mathematics and computer science. The objective is to place eight chess queens on an 8×8 chessboard so that no two queens threaten each other—meaning no two queens share the same row, column, or diagonal. This GeoGebra applet provides an interactive visualization that helps students understand both the constraints of the puzzle and the process of finding valid solutions. The applet constructs a proper chessboard grid using Polygon, Sequence, and conditional formatting commands. It displays coordinate points labeled systematically (such as p11 through p88) representing each square on the board. Users can drag queens onto the board or watch automated solution sequences play out. The visualization highlights violated constraints in real time—when two queens attack each other along any line, the conflicting positions become visually apparent through color coding or connecting lines. This tool demonstrates several important mathematical concepts. First, it illustrates constraint satisfaction problems, showing how a valid solution must satisfy multiple simultaneous conditions. Second, it provides visual intuition for symmetry in problem-solving, as many of the 92 known solutions relate to each other through reflections and rotations. Third, it introduces students to algorithmic thinking, as they can observe backtracking strategies when the applet searches for solutions systematically. The interactive nature of the applet benefits students by making abstract constraints concrete. Rather than reading about the rules, learners see immediately what happens when they place queens incorrectly. This trial-and-error exploration builds deeper understanding than passive observation. The visualization also supports multiple learning styles—kinesthetic learners benefit from dragging pieces, while visual learners appreciate seeing constraint violations highlighted. For educators, this applet serves as an excellent classroom demonstration tool. It can introduce topics ranging from basic combinatorics to advanced algorithm design depending on the course level. The fact that there are exactly 92 distinct solutions (12 fundamental solutions when accounting for symmetry) makes it ideal for discussions about enumeration and optimization. The applet's construction using GeoGebra's programming commands—Polygon for the board, Sequence for systematic placement, and If statements for constraint checking—also serves as a model for students learning computational thinking. By examining how these commands work together, students gain insight into how mathematical problems translate into executable procedures, bridging the gap between pure mathematics and computer science applications.

GeoGebra Commands & Parameters

  1. Polygon({(2 - 0.5, 1 - 0.5), (2 + 0.5, 1 - 0.5), (2 + 0.5, 1 + 0.5), (2 - 0.5, 1 + 0.5)}) → p21
  2. Polygon({(3 - 0.5, 1 - 0.5), (3 + 0.5, 1 - 0.5), (3 + 0.5, 1 + 0.5), (3 - 0.5, 1 + 0.5)}) → p31
  3. Polygon({(4 - 0.5, 1 - 0.5), (4 + 0.5, 1 - 0.5), (4 + 0.5, 1 + 0.5), (4 - 0.5, 1 + 0.5)}) → p41
  4. Polygon({(5 - 0.5, 1 - 0.5), (5 + 0.5, 1 - 0.5), (5 + 0.5, 1 + 0.5), (5 - 0.5, 1 + 0.5)}) → p51
  5. Polygon({(6 - 0.5, 1 - 0.5), (6 + 0.5, 1 - 0.5), (6 + 0.5, 1 + 0.5), (6 - 0.5, 1 + 0.5)}) → p61
  6. Polygon({(7 - 0.5, 1 - 0.5), (7 + 0.5, 1 - 0.5), (7 + 0.5, 1 + 0.5), (7 - 0.5, 1 + 0.5)}) → p71
  7. Polygon({(8 - 0.5, 1 - 0.5), (8 + 0.5, 1 - 0.5), (8 + 0.5, 1 + 0.5), (8 - 0.5, 1 + 0.5)}) → p81
  8. Polygon({(1 - 0.5, 1 - 0.5), (1 + 0.5, 1 - 0.5), (1 + 0.5, 1 + 0.5), (1 - 0.5, 1 + 0.5)}) → p11
  9. Polygon({(7 - 0.5, 2 - 0.5), (7 + 0.5, 2 - 0.5), (7 + 0.5, 2 + 0.5), (7 - 0.5, 2 + 0.5)}) → p72
  10. Polygon({(6 - 0.5, 2 - 0.5), (6 + 0.5, 2 - 0.5), (6 + 0.5, 2 + 0.5), (6 - 0.5, 2 + 0.5)}) → p62
  11. Polygon({(5 - 0.5, 2 - 0.5), (5 + 0.5, 2 - 0.5), (5 + 0.5, 2 + 0.5), (5 - 0.5, 2 + 0.5)}) → p52
  12. Polygon({(4 - 0.5, 2 - 0.5), (4 + 0.5, 2 - 0.5), (4 + 0.5, 2 + 0.5), (4 - 0.5, 2 + 0.5)}) → p42
  13. Polygon({(3 - 0.5, 2 - 0.5), (3 + 0.5, 2 - 0.5), (3 + 0.5, 2 + 0.5), (3 - 0.5, 2 + 0.5)}) → p32
  14. Polygon({(2 - 0.5, 2 - 0.5), (2 + 0.5, 2 - 0.5), (2 + 0.5, 2 + 0.5), (2 - 0.5, 2 + 0.5)}) → p22
  15. Polygon({(1 - 0.5, 2 - 0.5), (1 + 0.5, 2 - 0.5), (1 + 0.5, 2 + 0.5), (1 - 0.5, 2 + 0.5)}) → p12
  16. Polygon({(8 - 0.5, 2 - 0.5), (8 + 0.5, 2 - 0.5), (8 + 0.5, 2 + 0.5), (8 - 0.5, 2 + 0.5)}) → p82
  17. Polygon({(7 - 0.5, 3 - 0.5), (7 + 0.5, 3 - 0.5), (7 + 0.5, 3 + 0.5), (7 - 0.5, 3 + 0.5)}) → p73
  18. Polygon({(6 - 0.5, 3 - 0.5), (6 + 0.5, 3 - 0.5), (6 + 0.5, 3 + 0.5), (6 - 0.5, 3 + 0.5)}) → p63
  19. Polygon({(5 - 0.5, 3 - 0.5), (5 + 0.5, 3 - 0.5), (5 + 0.5, 3 + 0.5), (5 - 0.5, 3 + 0.5)}) → p53
  20. Polygon({(4 - 0.5, 3 - 0.5), (4 + 0.5, 3 - 0.5), (4 + 0.5, 3 + 0.5), (4 - 0.5, 3 + 0.5)}) → p43
  21. Polygon({(3 - 0.5, 3 - 0.5), (3 + 0.5, 3 - 0.5), (3 + 0.5, 3 + 0.5), (3 - 0.5, 3 + 0.5)}) → p33
  22. Polygon({(2 - 0.5, 3 - 0.5), (2 + 0.5, 3 - 0.5), (2 + 0.5, 3 + 0.5), (2 - 0.5, 3 + 0.5)}) → p23
  23. Polygon({(1 - 0.5, 3 - 0.5), (1 + 0.5, 3 - 0.5), (1 + 0.5, 3 + 0.5), (1 - 0.5, 3 + 0.5)}) → p13
  24. Polygon({(8 - 0.5, 3 - 0.5), (8 + 0.5, 3 - 0.5), (8 + 0.5, 3 + 0.5), (8 - 0.5, 3 + 0.5)}) → p83
  25. Polygon({(6 - 0.5, 4 - 0.5), (6 + 0.5, 4 - 0.5), (6 + 0.5, 4 + 0.5), (6 - 0.5, 4 + 0.5)}) → p64
  26. Polygon({(4 - 0.5, 4 - 0.5), (4 + 0.5, 4 - 0.5), (4 + 0.5, 4 + 0.5), (4 - 0.5, 4 + 0.5)}) → p44
  27. Polygon({(3 - 0.5, 4 - 0.5), (3 + 0.5, 4 - 0.5), (3 + 0.5, 4 + 0.5), (3 - 0.5, 4 + 0.5)}) → p34
  28. Polygon({(2 - 0.5, 4 - 0.5), (2 + 0.5, 4 - 0.5), (2 + 0.5, 4 + 0.5), (2 - 0.5, 4 + 0.5)}) → p24
  29. Polygon({(1 - 0.5, 4 - 0.5), (1 + 0.5, 4 - 0.5), (1 + 0.5, 4 + 0.5), (1 - 0.5, 4 + 0.5)}) → p14
  30. Polygon({(5 - 0.5, 4 - 0.5), (5 + 0.5, 4 - 0.5), (5 + 0.5, 4 + 0.5), (5 - 0.5, 4 + 0.5)}) → p54
  31. Polygon({(7 - 0.5, 4 - 0.5), (7 + 0.5, 4 - 0.5), (7 + 0.5, 4 + 0.5), (7 - 0.5, 4 + 0.5)}) → p74
  32. Polygon({(8 - 0.5, 4 - 0.5), (8 + 0.5, 4 - 0.5), (8 + 0.5, 4 + 0.5), (8 - 0.5, 4 + 0.5)}) → p84
  33. Polygon({(7 - 0.5, 5 - 0.5), (7 + 0.5, 5 - 0.5), (7 + 0.5, 5 + 0.5), (7 - 0.5, 5 + 0.5)}) → p75
  34. Polygon({(5 - 0.5, 5 - 0.5), (5 + 0.5, 5 - 0.5), (5 + 0.5, 5 + 0.5), (5 - 0.5, 5 + 0.5)}) → p55
  35. Polygon({(4 - 0.5, 5 - 0.5), (4 + 0.5, 5 - 0.5), (4 + 0.5, 5 + 0.5), (4 - 0.5, 5 + 0.5)}) → p45
  36. Polygon({(3 - 0.5, 5 - 0.5), (3 + 0.5, 5 - 0.5), (3 + 0.5, 5 + 0.5), (3 - 0.5, 5 + 0.5)}) → p35
  37. Polygon({(2 - 0.5, 5 - 0.5), (2 + 0.5, 5 - 0.5), (2 + 0.5, 5 + 0.5), (2 - 0.5, 5 + 0.5)}) → p25
  38. Polygon({(1 - 0.5, 5 - 0.5), (1 + 0.5, 5 - 0.5), (1 + 0.5, 5 + 0.5), (1 - 0.5, 5 + 0.5)}) → p15
  39. Polygon({(6 - 0.5, 5 - 0.5), (6 + 0.5, 5 - 0.5), (6 + 0.5, 5 + 0.5), (6 - 0.5, 5 + 0.5)}) → p65
  40. Polygon({(8 - 0.5, 5 - 0.5), (8 + 0.5, 5 - 0.5), (8 + 0.5, 5 + 0.5), (8 - 0.5, 5 + 0.5)}) → p85
  41. Polygon({(7 - 0.5, 6 - 0.5), (7 + 0.5, 6 - 0.5), (7 + 0.5, 6 + 0.5), (7 - 0.5, 6 + 0.5)}) → p76
  42. Polygon({(6 - 0.5, 6 - 0.5), (6 + 0.5, 6 - 0.5), (6 + 0.5, 6 + 0.5), (6 - 0.5, 6 + 0.5)}) → p66
  43. Polygon({(5 - 0.5, 6 - 0.5), (5 + 0.5, 6 - 0.5), (5 + 0.5, 6 + 0.5), (5 - 0.5, 6 + 0.5)}) → p56
  44. Polygon({(4 - 0.5, 6 - 0.5), (4 + 0.5, 6 - 0.5), (4 + 0.5, 6 + 0.5), (4 - 0.5, 6 + 0.5)}) → p46
  45. Polygon({(3 - 0.5, 6 - 0.5), (3 + 0.5, 6 - 0.5), (3 + 0.5, 6 + 0.5), (3 - 0.5, 6 + 0.5)}) → p36
  46. Polygon({(2 - 0.5, 6 - 0.5), (2 + 0.5, 6 - 0.5), (2 + 0.5, 6 + 0.5), (2 - 0.5, 6 + 0.5)}) → p26
  47. Polygon({(1 - 0.5, 6 - 0.5), (1 + 0.5, 6 - 0.5), (1 + 0.5, 6 + 0.5), (1 - 0.5, 6 + 0.5)}) → p16
  48. Polygon({(8 - 0.5, 6 - 0.5), (8 + 0.5, 6 - 0.5), (8 + 0.5, 6 + 0.5), (8 - 0.5, 6 + 0.5)}) → p86
  49. Polygon({(7 - 0.5, 7 - 0.5), (7 + 0.5, 7 - 0.5), (7 + 0.5, 7 + 0.5), (7 - 0.5, 7 + 0.5)}) → p77
  50. Polygon({(6 - 0.5, 7 - 0.5), (6 + 0.5, 7 - 0.5), (6 + 0.5, 7 + 0.5), (6 - 0.5, 7 + 0.5)}) → p67
  51. Polygon({(5 - 0.5, 7 - 0.5), (5 + 0.5, 7 - 0.5), (5 + 0.5, 7 + 0.5), (5 - 0.5, 7 + 0.5)}) → p57
  52. Polygon({(4 - 0.5, 7 - 0.5), (4 + 0.5, 7 - 0.5), (4 + 0.5, 7 + 0.5), (4 - 0.5, 7 + 0.5)}) → p47
  53. Polygon({(3 - 0.5, 7 - 0.5), (3 + 0.5, 7 - 0.5), (3 + 0.5, 7 + 0.5), (3 - 0.5, 7 + 0.5)}) → p37
  54. Polygon({(2 - 0.5, 7 - 0.5), (2 + 0.5, 7 - 0.5), (2 + 0.5, 7 + 0.5), (2 - 0.5, 7 + 0.5)}) → p27
  55. Polygon({(1 - 0.5, 7 - 0.5), (1 + 0.5, 7 - 0.5), (1 + 0.5, 7 + 0.5), (1 - 0.5, 7 + 0.5)}) → p17
  56. Polygon({(8 - 0.5, 7 - 0.5), (8 + 0.5, 7 - 0.5), (8 + 0.5, 7 + 0.5), (8 - 0.5, 7 + 0.5)}) → p87
  57. Polygon({(7 - 0.5, 8 - 0.5), (7 + 0.5, 8 - 0.5), (7 + 0.5, 8 + 0.5), (7 - 0.5, 8 + 0.5)}) → p78
  58. Polygon({(6 - 0.5, 8 - 0.5), (6 + 0.5, 8 - 0.5), (6 + 0.5, 8 + 0.5), (6 - 0.5, 8 + 0.5)}) → p68
  59. Polygon({(5 - 0.5, 8 - 0.5), (5 + 0.5, 8 - 0.5), (5 + 0.5, 8 + 0.5), (5 - 0.5, 8 + 0.5)}) → p58
  60. Polygon({(4 - 0.5, 8 - 0.5), (4 + 0.5, 8 - 0.5), (4 + 0.5, 8 + 0.5), (4 - 0.5, 8 + 0.5)}) → p48
  61. Polygon({(3 - 0.5, 8 - 0.5), (3 + 0.5, 8 - 0.5), (3 + 0.5, 8 + 0.5), (3 - 0.5, 8 + 0.5)}) → p38
  62. Polygon({(2 - 0.5, 8 - 0.5), (2 + 0.5, 8 - 0.5), (2 + 0.5, 8 + 0.5), (2 - 0.5, 8 + 0.5)}) → p28
  63. Polygon({(1 - 0.5, 8 - 0.5), (1 + 0.5, 8 - 0.5), (1 + 0.5, 8 + 0.5), (1 - 0.5, 8 + 0.5)}) → p18
  64. Polygon({(8 - 0.5, 8 - 0.5), (8 + 0.5, 8 - 0.5), (8 + 0.5, 8 + 0.5), (8 - 0.5, 8 + 0.5)}) → p88
  65. Join(Sequence[Sequence[(m, n), n, 1, 8], m, 1, 8]) → allM
  66. If(Length[queens] ≟ 0, {}, Unique[Join[Sequence[KeepIf[x(P) ≟ x(queens(k)) ∨ y(P) ≟ y(queens(k)) ∨ x(P) - x(queens(k)) ≟ y(P) - y(queens(k)) ∨ x(P) - x(queens(k)) ≟ (-y(P)) + y(queens(k)), P, allM], k, 1, Length[queens]]]]) → dots1
  67. Polygon({Corner[1], Corner[2], Corner[3], Corner[4]}) → polyBackground
  68. Sequence(Translate[picQueen, Vector[(9.5, 0.5), queens(k)]], k, 1, Length[queens]) → picQueens
  69. Length(queens) → numQueens
  70. Polygon({Corner[1], Corner[2], Corner[3], Corner[4]}) → polyMask

AI Drawing Prompt Reference

Draw an 8x8 chessboard with each square represented by a 1x1 square, starting from the top-left corner and drawing 8 squares in each row, for a total of 8 rows. Ensure there is a 0.5 spacing between adjacent squares.
The prompt above was compiled from the original drawing commands and is for reference only.