I am working on reproducing the Zero Information trader in Julia using Agents.jl. My agents include a field named :traded, which is of type Bool and is initialized to false for all agents. This is changed to true once an agent has been involved in a trade. In the model_step! function, I need to select a random agent that has not been involved in a trade. The code I have used is as follows:
trading_agent = random_agent(model, :traded == false)
where model is the instantiated model passed to the model_step! function.
This results in a MethodError indicating that object of type Bool are not callable. Looking at the documentation for Agents.jl I could not find an example where random_agent was used with a condition; nor could I find one in the Example Zoo, So, I tried a number of variations, to no avail, and finally used the following workaround, which is:
i = true
while i == true
trading_agent = random_agent(model)
i = trading_agent.traded
end
This works but is not very elegant and still leaves me wondering how to properly use random_agent.