I\'m replicating a small piece of Sugarscape agent simulation model in Python 3. I found the performance of my code is ~3 times slower than that of NetLogo. Is it likely the pro
I'm going to guess that the way that neighborhood
is implemented in NetLogo is different from the double loop you have. Specifically, I think they pre-calculate a neighborhood vector like
n = [ [0,1],[0,-1],[1,0],[-1,0]....]
(you would need a different one for vision=1,2,...) and then use just one loop over n
instead of a nested loop like you are doing. This eliminates the need for the multiplications.
I don't think this will get you 3X speedup.