SHARE
TWEET

Untitled

a guest May 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public void makeMove(int sidePitNum) throws IllegalSidePitNumException, IllegalMoveException
  2. {
  3. int currentTurn;
  4. currentTurn=this.getTurn();
  5. int currentStones =  getNumStones(sidePitNum);
  6. int position;
  7. if(currentTurn==0)
  8. {
  9. board[getSidePitArrayIndex(sidePitNum)]=0;
  10. position = getSidePitArrayIndex(sidePitNum);
  11. }
  12. else
  13. {
  14. board[getSidePitArrayIndex(sidePitNum+7)]=0;
  15. position = getSidePitArrayIndex(sidePitNum+7);
  16. }
  17.  
  18. for (int i=currentStones; i>0; i--)
  19. {
  20. position++;
  21. if (position>13)
  22. position=0;
  23. board[position]++;
  24. }
  25.  
  26.  
  27.  
  28.  
  29. int captured=0;
  30.  
  31. if (board[position]==1)
  32. if(currentTurn==0 && position<6)
  33. {captured+=board[position];
  34. board[position]=0;
  35. captured+=board[12-position];
  36. board[12-position]=0;
  37. board[6]+=captured;
  38. }
  39. else if (currentTurn==1 && position>6 && position<13)
  40. {captured+=board[position];
  41. board[position]=0;
  42. captured+=board[12-position];
  43. board[12-position]=0;
  44. board[13]+=captured;
  45. }
  46.  
  47. if ((currentTurn==0 && position!=6 ) || (currentTurn==1 && position!=13))
  48.     if (currentTurn==0)
  49.         turnOfPlayer=1;
  50.     else turnOfPlayer=0;
  51. }
RAW Paste Data
Top