Guest User

Untitled

a guest
Apr 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public static boolean canPut(int[]tile, int x, int y, int[][][] board) {
  2. boolean ans = true;
  3. if(x>board.length | y>board.length)
  4. return false;
  5. else
  6. {
  7. if(board[x][y]==null)
  8. {
  9. if((x==0 && west(tile)!=0) || (y==0 && north(tile)!=0) || (x==board.length-1 && east(tile)!=0) || (y==board.length-1 && south(tile)!=0))
  10. ans=false;
  11. else
  12. {
  13. if(x==0)
  14. {
  15. if((board[y-1][x]!=null && (north(tile)!=south(board[y-1][x]))) || (board[y][x+1]!=null && (east(tile)!=west(board[y][x+1]))) || (board[y+1][x]!=null && south(tile)!=north(board[y+1][x])))
  16. ans=false;
  17. }
  18. else if(x==board.length-1)
  19. {
  20. if((board[y-1][x]!=null && (north(tile)!=south(board[y-1][x]))) || (board[y][x-1]!=null && (west(tile)!=east(board[y][x-1]))) || (board[y+1][x]!=null && south(tile)!=north(board[y+1][x])))
  21. ans=false;
  22. }
  23. else if(y==0)
  24. {
  25. if((board[y][x-1]!=null && (west(tile)!=east(board[y][x-1]))) || (board[y][x+1]!=null && (east(tile)!=west(board[y][x+1]))) || (board[y+1][x]!=null && south(tile)!=north(board[y+1][x])))
  26. ans=false;
  27. }
  28. else if(y==board.length-1)
  29. {
  30. if((board[y-1][x]!=null && (north(tile)!=south(board[y-1][x]))) || (board[y][x+1]!=null && (east(tile)!=west(board[y][x+1]))) || (board[y][x-1]!=null && west(tile)!=east(board[y][x-1])))
  31. ans=false;
  32. }
  33. else if(x>0 && x<tile.length-1 && y>0 && y<tile.length-1)
  34. {
  35. if((board[y-1][x]!=null && (north(tile)!=south(board[y-1][x]))) || (board[y][x+1]!=null && (east(tile)!=west(board[y][x+1]))) || (board[y][x-1]!=null && west(tile)!=east(board[y][x-1])) || (board[y+1][x]!=null && south(tile)!=north(board[y+1][x])))
  36. ans=false;
  37. }
  38. }
  39. }
  40. else ans=false;
  41. }
  42.  
  43. return ans;
  44. }
Add Comment
Please, Sign In to add comment