% SeeLongForm %Created by Alan Mehlenbacher function [temps, tempi, tempj] = seeLongForm(i,j,k,a_str,s,size,temps,tempi,tempj); %Without using the control arrays (but not random order) %South if (i+k > size) %Check if searching off the South edge u = i+k-size; %Sugarscape is a torus, so wrap around to the North v = j; [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); else u = i+k; v = j; [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); end %North if (k-i > -1) %Check if searching off the North edge i-k+size; %Sugarscape is a torus, so wrap around to the South v = j; [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); else u = i-k ; v = j; [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); end %East if (j+k > size) %Check if searching off the East edge u = i; v = j+k-size; %Wrap around to the West [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); else u = i; v = j+k; [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); end %West if (k-j > -1) %Check if searching off the West edge u = i; v = j-k+size ; %Wrap around to the East [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); else u = i; v = j-k; [temps, tempi, tempj] = neighbor(u,v,a_str,s,temps,tempi,tempj); end %temps contains the current best level of sugar and this best level is %located in cell (tempi,tempj)