Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean canPut(int[]tile, int x, int y, int[][][] board) {
- boolean ans = true;
- if(x>board.length | y>board.length)
- return false;
- else
- {
- if(board[x][y]==null)
- {
- 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))
- ans=false;
- else
- {
- if(x==0)
- {
- 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])))
- ans=false;
- }
- else if(x==board.length-1)
- {
- 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])))
- ans=false;
- }
- else if(y==0)
- {
- 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])))
- ans=false;
- }
- else if(y==board.length-1)
- {
- 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])))
- ans=false;
- }
- else if(x>0 && x<tile.length-1 && y>0 && y<tile.length-1)
- {
- 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])))
- ans=false;
- }
- }
- }
- else ans=false;
- }
- return ans;
- }
Add Comment
Please, Sign In to add comment