Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Cache
- var pre_op = getOperations() ;
- global neighbours_cache = [] ;
- for(var j=-17;j<17;j++){
- for(var i=-17;i<17;i++){
- var cell = getCellFromXY(i, j) ;
- var neigbour = 0 ;
- //i-1;j
- if(i>-17){
- var sub_cell = getCellFromXY(i-1, j) ;
- if(sub_cell != null){
- if(!isObstacle(sub_cell)
- or !isLeek(sub_cell)){
- neigbour += 8 ;
- }
- }
- }
- //i;j-1
- if(j>-17){
- var sub_cell = getCellFromXY(i, j-1) ;
- if(sub_cell != null){
- if(!isObstacle(sub_cell)
- or !isLeek(sub_cell)){
- neigbour += 4 ;
- }
- }
- }
- //i+1;j
- if(i<17){
- var sub_cell = getCellFromXY(i+1, j) ;
- if(sub_cell != null){
- if(!isObstacle(sub_cell)
- or !isLeek(sub_cell)){
- neigbour += 2 ;
- }
- }
- }
- //i;j+1
- if(j<17){
- var sub_cell = getCellFromXY(i, j+1) ;
- if(sub_cell != null){
- if(!isObstacle(sub_cell)
- or !isLeek(sub_cell)){
- neigbour += 1 ;
- }
- }
- }
- neighbours_cache[cell] = neigbour ;
- }
- }
- debug(getOperations()-pre_op-2) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement