Advertisement
Guest User

Lee Nim Lab

a guest
Oct 20th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class LeeNim
  2. {
  3.   int numberOfPieces = 0;
  4.  
  5.  public LeeNim()
  6.   {
  7.     numberOfPieces = 13;
  8.   }  
  9.   public LeeNim(int numPieces)
  10.   {
  11.     numberOfPieces = numPieces;
  12.   }
  13.   public int play(int pieces)
  14.   {
  15.     if (pieces == 12 || pieces == 10 || pieces == 9 || pieces == 6 || pieces == 3)//I made it so the computer will take away the opposite of whatever the human does
  16.     {
  17.       return 2;
  18.     }//by doing that, the numbers will always end up the same after the computer's turn. 10-7-4 until the computer wins.
  19.    
  20.     if (pieces == 11 || pieces == 8 || pieces == 7 || pieces == 5 || pieces == 4 || pieces == 2)
  21.     {
  22.       return 1;
  23.     }
  24.     else return 0;
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement