+
The Subtraction Game
+
+ {/* Game Controls */}
+
+
+ {/* N Slider */}
+
+
+
+
+
+ {/* K Slider */}
+
+
+
+
+
+
+
+
+
+
+
+ {/* Game Status */}
+ {gameStarted && !winner && (
+
+
+ {currentPlayer}'s Turn
+
+
+ Click on any highlighted circle to make your move
+
+
+ )}
+
+ {/* Winner Display */}
+ {winner && (
+
+
+ 🎉 {winner} Wins! 🎉
+
+
+ {winner} made the last move and won the game!
+
+
+ )}
+
+ {/* Game Board */}
+ {circles.length > 0 && (
+
+
+ {circles.map((_, index) => (
+
handleCircleClick(index)}
+ title={highlightedIndices.includes(index) ? 'Click to select' : 'Not selectable'}
+ />
+ ))}
+
+
+ {circles.length > 0 && (
+
+
+ {highlightedIndices.length} circle(s) highlighted • Last {Math.min(k[0], circles.length)} positions
+
+
+ )}
+
+ )}
+
+ {/* Game Rules */}
+
+
How to Play
+
+ - • Set the number of circles (n) and maximum selection range (k)
+ - • Players take turns clicking on highlighted circles
+ - • When you click a circle, all circles to its right disappear
+ - • The last k circles (or fewer if less than k remain) are always highlighted
+ - • The player who makes the last move wins!
+ - • Background color indicates whose turn it is
+
+
+
+