Nim Project
From Huben's Wiki
(→Graphical Nim) |
(→Graphical Nim) |
||
Line 41: | Line 41: | ||
== Graphical Nim == | == Graphical Nim == | ||
# Ch. 15 (Graphics) | # Ch. 15 (Graphics) | ||
− | + | ## get some text in the box from the Display project | |
# Build a pyramid of circles with height and base of 4 circles. | # Build a pyramid of circles with height and base of 4 circles. | ||
− | + | ## start with a right triangle | |
− | + | ## adjust x coords to make pyramid | |
− | + | ## adjust coords to center pyramid | |
− | + | ## adjust coords to allow pyramid to resize with window | |
− | + | ### use min of width and height | |
# Use pyramid to display board instead of text | # Use pyramid to display board instead of text | ||
# Optional: add computer player misere version (lose if take last) | # Optional: add computer player misere version (lose if take last) | ||
− | + | ## if (all rows 2 or less) // endgame | |
− | + | ### maintain odd number of rows with one | |
− | + | ## else // midgame | |
− | + | ### // nimsum = binary exclusive or of all row counts | |
− | + | ### if nimsum == 0 // no forced win | |
− | + | #### make any move | |
− | + | ### else // forced win | |
− | + | #### remove nimsum pieces from any row | |
# Read next two chapters, build with point and click interface. | # Read next two chapters, build with point and click interface. |