Created
March 1, 2013 22:33
-
-
Save Ram-N/5068470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Are any of the 4 diagonally adjacent cells occupied? | |
isAnyDiagNeighboringCellOccupied <- function(m,n) { | |
canOccupy <- FALSE | |
diag.dir = c(1,3,6,8) | |
#traverse the vector of 4 elements | |
for(k in 1:4) { | |
xCheck = m + adjacells[diag.dir[k],1] | |
yCheck = n + adjacells[diag.dir[k],2] | |
if(!(outOfBounds(xCheck, yCheck))) { | |
if(area_df[xCheck, yCheck] >0 ) { | |
print(paste("area df of ", xCheck, yCheck, area_df[xCheck, yCheck])) | |
print(paste("(",m,",",n,")" ,"DIAGONAL neighbor of (", yCheck, "-", xCheck)) | |
canOccupy <- TRUE | |
} | |
} | |
} #end of looping through k | |
return(canOccupy) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment