So, jumping from file to file to learn about the a.i. I reached this:
The AI Component uses a special election process to determine which Action gets to run. Specifically:
- All Actions are asked to “start_thinking” simultaneously. “start_thinking” is the mechanism by which an Action is informed that the AI Component would like to run it.
- The Action which returns a result first is immediately run.
- If multiple Actions all return a result simultaneously, the one with the highest priority gets run.
- If multiple Actions all have the same priority, they are weighted by the “weight” field in their header and a random Action is chosen.
About the second step:
Does it means that even if my a.i. have a higher priority this does not guarantee that it will run because another task can be completed first?
And if that is the case, what exactly makes it return first? Just the code “heaviness”? A code full of loops and functions calls would probably take longer to return than a simple check with an if statement.