Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860
Nim Project - Huben's Wiki

Nim Project

From Huben's Wiki
Jump to: navigation, search
(C-:)
 
Line 2: Line 2:
 
This project will use several things we've encountered in other assignments in the past.
 
This project will use several things we've encountered in other assignments in the past.
  
To get a grade, you must complete the bulleted items following it.
+
You may get any help you want, as long as you DOCUMENT it.  Put the provenance of the help in your code as a comment at the top.  For example:
 +
<pre>
 +
// Fred helped me with the toString() method.
 +
// I found code for a nim sum online at xxxx and adapted it for my program.
 +
</pre>
 +
This will prevent problems of plagiarism.  Please don't give each other code: write your own when you understand what is involved.  Ask me if you are unsure or stuck: nobody needs to suffer for being stuck.
 +
 
 +
To get a grade, you must complete the bulleted items following it.  Please make sure I give you a D before you go on to do more and get a higher grade.  I should grade your program at least twice as you progress.
  
 
===D:===
 
===D:===
Line 18: Line 25:
 
* Use a Scanner in a loop to input a row LETTER (either upper or lower case) and number of stones to remove.  (Page 26 of text.)
 
* Use a Scanner in a loop to input a row LETTER (either upper or lower case) and number of stones to remove.  (Page 26 of text.)
 
* The loop should only exit when a valid move has been selected.
 
* The loop should only exit when a valid move has been selected.
 +
* When a move is invalid, the loop should tell you why it is invalid.
 +
* When a move is valid, the loop should tell you "Removing x from pile Y."
 
* Use Scanner.nextLine() instead of nextInt(): it is more robust.
 
* Use Scanner.nextLine() instead of nextInt(): it is more robust.
 +
* the easy way is to just look at the first character, if it exists, for row or stones
 +
* it would be nicer if we could type b2 at one input to take two from row B.
 
* tests for valid row should reject:
 
* tests for valid row should reject:
 
** a simple return without typing anything
 
** a simple return without typing anything
Line 30: Line 41:
 
** more stones than in the row
 
** more stones than in the row
 
** anything not a number
 
** anything not a number
* the easy way is to just look at the first character, if it exists, for row or stones
+
 
* it would be nicer if we could type b2 at one input to take two from row B.
+
  
 
===C+===
 
===C+===
Line 47: Line 57:
  
 
== Graphical Nim ==
 
== Graphical Nim ==
 +
===D===
 
# Ch. 15 (Graphics)
 
# Ch. 15 (Graphics)
## get some text in the box from the Display project
+
## start with the box from studentdisk/Ch15/Exercises/Drawings.java
 +
## change the box to a filled circle
 +
===C+===
 +
# Read "Creating the graphical Nim board."
 
# 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
 
## start with a right triangle
Line 55: Line 69:
 
## adjust coords to allow pyramid to resize with window
 
## adjust coords to allow pyramid to resize with window
 
### use min of width and height
 
### use min of width and height
 +
### you ought to be able to have pyramids of other sizes too
 +
===B+===
 
# 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)
+
===A+===
## 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.

Latest revision as of 12:25, 11 June 2013

Personal tools
translate