function run(steps)
%asynchronous updating of individual nodes
%steps determines how many nodes are updated (sampling with replacement)

global Nunits nodes synapses

figure(1)

for i=1:steps
    node = randi(Nunits); %random unit to update
    nodes(node) = sign(synapses(node,:)*nodes + .01); %update this unit; .01 is tiebreaker to avoid getting zero
    row = round(node/sqrt(Nunits)-.5); %row location of selected node in figure
    column = node - row*sqrt(Nunits); %column location of selected node in figure
    if nodes(node)==1 %if node is ON, plot in black
        plot(column,sqrt(Nunits)-row,'sr','markerfacecolor','black','markeredgecolor','black')
    else %if node if OFF, plot in yellow
        plot(column,sqrt(Nunits)-row,'sr','markerfacecolor',[1 1 0],'markeredgecolor',[.8 .8 0])
    end
end

