Advertisement
Guest User

Untitled

a guest
May 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. //Cache
  2.  
  3. var pre_op = getOperations() ;
  4.  
  5. global neighbours_cache = [] ;
  6.  
  7. for(var j=-17;j<17;j++){
  8. for(var i=-17;i<17;i++){
  9. var cell = getCellFromXY(i, j) ;
  10. var neigbour = 0 ;
  11. //i-1;j
  12. if(i>-17){
  13. var sub_cell = getCellFromXY(i-1, j) ;
  14. if(sub_cell != null){
  15. if(!isObstacle(sub_cell)
  16. or !isLeek(sub_cell)){
  17. neigbour += 8 ;
  18. }
  19. }
  20. }
  21. //i;j-1
  22. if(j>-17){
  23. var sub_cell = getCellFromXY(i, j-1) ;
  24. if(sub_cell != null){
  25. if(!isObstacle(sub_cell)
  26. or !isLeek(sub_cell)){
  27. neigbour += 4 ;
  28. }
  29. }
  30. }
  31. //i+1;j
  32. if(i<17){
  33. var sub_cell = getCellFromXY(i+1, j) ;
  34. if(sub_cell != null){
  35. if(!isObstacle(sub_cell)
  36. or !isLeek(sub_cell)){
  37. neigbour += 2 ;
  38. }
  39. }
  40. }
  41. //i;j+1
  42. if(j<17){
  43. var sub_cell = getCellFromXY(i, j+1) ;
  44. if(sub_cell != null){
  45. if(!isObstacle(sub_cell)
  46. or !isLeek(sub_cell)){
  47. neigbour += 1 ;
  48. }
  49. }
  50. }
  51. neighbours_cache[cell] = neigbour ;
  52. }
  53. }
  54. debug(getOperations()-pre_op-2) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement