Demo of Enact
%enact is a function shose inputs are action, taking values 0,1, or -1, and %b, a local ball. the output of the function is actual_action, also a %number that is 0,1, or -1. action = -1; b = [0 0 1 1 0 0 0]; midval = (length(b)+1)/2 %this computes the position of the center agent who is acting actual_action = action*(b(midval + action) == 0) %this computes whether the agent is %trying to move into a place where there's already an agent; if not, the original %action is OK; otherwise, the action is canceled (set to 0)
midval = 4 actual_action = 0