Guest User

Untitled

a guest
Feb 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. private Piece TRules(Piece p, boolean[][] board) {
  2. int destCol = -1;
  3. int curColHeight = -1;
  4.  
  5. // checks for -_-
  6. for (int col = 1; col < MAXCOL; col++) {
  7. curColHeight = colHeight(board, col);
  8. if (curColHeight + 1 == colHeight(board, col - 1) &&
  9. curColHeight + 1 == colHeight(board, col + 1)) {
  10. p = rotateTo(p, 0);
  11. p = moveTo(p, col);
  12. p = p.drop();
  13. return p;
  14. }
  15. }
  16.  
  17. // checks for _-
  18. for (int col = 0; col < MAXCOL; col++) {
  19. curColHeight = colHeight(board, col);
  20. if (curColHeight + 1 == colHeight(board, col + 1)) {
  21. p = rotateTo(p, 3);
  22. p = moveTo(p, col);
  23. p = p.drop();
  24. return p;
  25. }
  26. }
  27.  
  28.  
  29. // checks for -_
  30. for (int col = 1; col <= MAXCOL; col++) {
  31. curColHeight = colHeight(board, col);
  32. if (curColHeight + 1 == colHeight(board, col - 1)) {
  33. p = rotateTo(p, 1);
  34. p = moveTo(p, col);
  35. p = p.drop();
  36. return p;
  37. }
  38. }
  39.  
  40. // the entire line must be straight at this point //!!! or sections of 2
  41. p = rotateTo(p, 2);
  42. p = moveTo(p, 0);
  43. p = p.drop();
  44. return p;
  45. }
Add Comment
Please, Sign In to add comment