title: Nim Game Example Static and Random Issues
body: <p>I'm having issues with my loop. The loop i think works fine in theory its just that when I try to you pile it says it needs to be static. I change it to static then generator for the Random number doesnt work anymore any suggestions would be appreciated.</p>
  
  <p>Question
  The game of Nim. This is a well-known game with a number of variants. The following variant has an interesting winning strategy. Two players alternately take marbles from a pile. In each move, a player chooses how many marbles to take. The player must take at least one but at most half of the marbles. Then the other player takes a turn. The player who takes the last marble loses.</p>
  
  <p>For Example.  If the initial pile starts at 100 then player 1 can take anywhere between 1 - 50 marbles.  Let's assume player 1 takes 20 marbles cutting the pile down to 80 marbles.  Player 2 can take anywhere between 1 - 40 marbles.  This continues until all the marbles are gone.</p>
  
  <p>Write a program in which the computer players against a human opponent. Generate a random integer between 10 and 100 to denote the initial size of the pile. Generate a random integer between 0 and 1 to decide whether the computer or the human takes the first turn. Generate a random integer between 0 and 1 to decide whether the computer plays smart or stupid. In stupid mode the computer simply takes a random legal value (between 1 and n/2) from the pile whenever it has a turn. In smart mode the computer takes off enough marbles to make the size of the pile a power of two minus 1 -  that is, 3, 7, 15, 31, or 63. That is always a legal move, except when the size of the pile is currently one less than a power of two. In that case, the computer makes a random legal move (a value between 1 and n / 2).</p>
  
  <p>You will note that the computer cannot be beaten in smart mode when it has the first move, unless the pile size happens to be 15, 31, or 63. Of course, a human player who has the first turn and knows the winning strategy can win against the computer.</p>
  
  <p>NOTE: You do not have to worry about rounding when the numbers you are working with are odd.  Simply use integer division which will truncate (remove with no rounding) the decimal places of the division.</p>
  
  <p>MY CODE</p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  public class Nim
  { Random generator= new Random();
      int turn= generator.nextInt(2);
   int pile= generator.nextInt(91) + 10;
      int smartDumb= generator.nextInt(2);
     Scanner in= new Scanner(System.in);
  
       public static void main(String [] args){
        String Comp;
           int currentPile= pile;
  
            while (pile&gt;0){
               int take=0;
  
                if(smartDumb==1)
                                  Comp="dumb";
                                  else Comp= "smart";
                  if (turn == 1)
                         turn = 0;
                  else
                         turn = 1;
                         {
                               if (turn==0){
                                   System.out.println("Please take some marbles.");
                                   currentPile=pile-in.nextInt();
                                   turn=1;
                                  }
                                  else 
                                   if (comp="dumb")
                                   take= generator.nextInt(1,currentPile);
                                   Currentpile= currentPile-take;
  
                                  if (comp=="smart")
                                  if (currentPile &gt; 64)
                                      currentPile=63;
                                  if (currentPile &gt; 32 &amp;&amp; currentPile &lt; 63)
                                      currentPile=31;
                                  if (currentPile &gt; 16 &amp;&amp; currentPile &lt; 31)
                                      currentPile=15;
                                  if (currentPile &gt; 8 &amp;&amp; currentPile &lt; 15)
                                      currentPile=7;
                                  if (currentPile &gt; 4 &amp;&amp; currentPile &lt; 7)
                                  currentPile=3;
                                  if (currentPile == 2)
                                  currentPile = 1;
                                  if (currentPile==1)
                                  currentPile=0;
  
                                  System.out.println("The game is over!");
                                  break;
  
  
  
  
          }
      }
  }}
  </code></pre>