Welcome @amynang !
Global variables are generally speaking bad practice for performant code, but in Agents.jl a “global” variable is most naturally represented as a model property. In this way, during any collision you simply increment this model property. For example, as in Schelling model in our docs, if you have the model properties
properties = Dict(:total_collisions => 0)
then inside your agent stepping function and/or the model stepping function you can do:
function agent_step!(agent, model)
if collision
model.total_colisions += 1
end
end