The 21 Game: A Variant of Nim
Loading the math board and drawing, please wait…
In collections
Math Games with GeoGebra (GGB)
This GeoGebra applet demonstrates the classic 21 Game, a well-known variant of the mathematical game of Nim. Two players, designated as Red and Blue, take turns removing 1, 2, or 3 objects from a shared pile, and the player who takes the 21st object wins. The applet features interactive buttons that allow users to select how many objects to remove on each turn, a dynamic state-tracking list that displays the game progress in real time, and built-in win-condition logic that automatically determines the winner once the 21st object is taken. Through this interactive setup, the model visually and intuitively illustrates key concepts from game theory, including optimal play and winning strategies rooted in modular arithmetic and the additive principle. Students will discover that controlling positions which are multiples of 4—namely 4, 8, 12, 16, and 20—is the key to securing victory, since whatever number of objects the opponent removes, the current player can always respond to reach the next multiple of 4. This hands-on exploration helps learners internalize strategic reasoning and pattern recognition in a playful context. The applet is ideally suited for interactive lessons in mathematical logic, combinatorial game theory, and sequence and series patterns, offering teachers a dynamic tool to engage students in discovering winning strategies through direct experimentation rather than passive instruction.
GeoGebra Commands & Parameters
Polygon({Corner[1], Corner[2], (x(Corner[3]), -3), (x(Corner[4]), -3)}) → backMLength(listLeft) → nleftPolygon({Corner[1], (-1, y(Corner[1])), (-1, y(Corner[4])), Corner[4]}) → backBPolygon({Corner[2], (5, y(Corner[2])), (5, y(Corner[3])), Corner[3]}) → backRPolygon({Corner[1], (-1, y(Corner[1])), (-1, y(Corner[4])), Corner[4]}) → maskBPolygon({Corner[2], (5, y(Corner[2])), (5, y(Corner[3])), Corner[3]}) → maskRSequence(Circle[(Mod[k, 5], 5 - floor(k / 5)), 0.4], k, 0, n - 1) → takeAllSequence(Circle[(Mod[listBlue(k) - 1, 5], 5 - floor((listBlue(k) - 1) / 5)), 0.4], k, 1, Length[listBlue]) → takeBSequence(Circle[(Mod[listRed(k) - 1, 5], 5 - floor((listRed(k) - 1) / 5)), 0.4], k, 1, Length[listRed]) → takeRSequence(Point[{(Mod[listTmp(k) - 1, 5], 5 - floor((listTmp(k) - 1) / 5))}], k, 1, Length[listTmp]) → takeTPolygon({(x(Corner[1]), -3), (x(Corner[2]), -3), Corner[3], Corner[4]}) → maskRulePolygon({Corner[1], Corner[2], (x(Corner[3]), -1), (x(Corner[4]), -1)}) → maskNewGameCircle(A, 0.2) → thinkingCCircleSector(A, A + ((0.2 * cos(90° - α)), (0.2 * sin(90° - α))), A + (0, 0.5)) → thinkingS
AI Drawing Prompt Reference
Create an interactive diagram showing the 21 Game where two players (Red and Blue) take turns removing 1 to 3 objects from a pile. Include a dynamic list tracking game progress, circles representing removed objects, and polygons indicating player colors. Add a rectangular area at the bottom for game status and a button at the top to start a new game. The layout should clearly distinguish player actions and game phases through color and shape.
The prompt above was compiled from the original drawing commands and is for reference only.