Back in the day I was working developing multiagent systems, particularly doing agent-based simulation or using multiple AI agents concurrently to solve problems. The frameworks I used back then (JADE, MASON, Netlogo) were designed to work with thousands of agents simultaneously. Even if there were not enough processors/threads to run all of them, they simulated concurrency by randomizing the order in which the agents were called. Calling agents always in the same order could produce bad results.
I’m considering moving from those multiagent frameworks to Unity to run my simulations, but I cannot find anywhere how Unity handles (or simulates) concurrency beyond knowing that it’s single threaded and synchronous (unless using coroutines). The job system seems better suited for specific tasks and not to add a thread for each object on screen, and even if using the job system it would be hard to have a systems with thousands of cores/threads to have real concurrency.
So, how does Unity choose the next script to execute? Is it in order of registration? Randomized? Something else? Can it be altered?
Thanks for your reply. The only thing I’m getting from the first link is that the scripts are executed in load order and that I can establish certain priorities, but it doesn’t really help with simulations if I need to randomize or somehow prevent always running the scripts in the same order.
The second link, I’ve looked into ECS before but that goes against agent-based simulations and multi-agent systems. It moves agency from the individual agents to the world so instead of a bottom-up approach to collective behaviour you get a top-down one.
The only thing I can think of is to create my own script manager. Have one Manager object with an Update script that calls a specific method in all agents in a random order. This seems very inefficient, though, as it would require a lot of overhead to register/de-register agents and probably complex code and large scripts if agents have a lot of functionality (compared to having one script per functionality as Unity encourages).