I have an idea for a modular AI system. The main goal is to allow this system to run anything from simple AI (fish) to advanced AI (villagers and combat squads). The second goal is to allow randomized diversity so that each instance of an AI is unique to some degree. The third goal is to allow for users to edit a base template to extend or implement new AI features. If you want a more detailed concept brief you can find a viewable PDF on my Google Drive here. I plan on using a custom editor for AI assembly. Here’s the AI Creator work flow:
- Create Species, includes group variables like species name and update frequency.
- Create Sensors, functions incorporating colliders, raycasts and parameters to understand surroundings.
- Create Mind, specify decision-making assessments and variables.
- Create Body, corresponding micro tasks (position, animations, etc)
- Create Tasks, sequential lists of micro tasks to perform.
A new AI species is given a name to distinguish itself from other AI species. A specie’s update parameter determines how frequently all AI instances of that species type will update. Sensors aim to mimic vision, scent, and sound. Each Sensor type has an unique process of detection. When a sensor properly detects, it notifies the Mind. The Mind accounts for detections, individual stats, and memory while making choices. The Mind follows a core sequential checklist:
-
Individual Assessment
-
assess detectable threats, assign priority to each threat based on variable thresholds
-
assess personal well being, assign priority to each stat based on variable thresholds
-
set desired task based on threat and/or variable priority comparisons
-
Actuation
-
Continue current task, or change current task based on desired task. Run task.
Some AI are more intelligent. By adding more core sequences to the Mind, the AI species gains more capabilities and assessment power. New capabilities come in the form of available tasks and alternative checklists. Basic tasks handle basic life functions such as: eating, sleeping, moving, fight, flight, and search. More intelligent tasks include: hunting, fishing, mining, building, and so on. Furthermore, some AI can be part of an active group, such as a clan, squad, village, and culture. Most groups provide more statistical modifiers while assessing, while others take control of the AI’s Individual Assessment and operate on different core sequences.
- Squad Assessment – if not in squad, perform the next core sequence.
- Individual Assessment – if not in serious danger, perform the next core sequence
- Group Assessment – if group has no needs, perform next core sequence
- Task Assessment – compare all priority assessments from previous core sequences, set current task
- Actuation – continue or initiate current task.
The Body handles all the animations and movement. It contains most micro tasks. A micro task is a function that handles a very explicit action, such as: animations, look at, move to, and so on. The Body is used primarily by the Task script. The Task script is given a specific task to perform. Each task is a set of micro actions to be activated sequentially governed by smaller assessments.
When a new AI is complete, the AI Creator generates a new Prefab with all the game objects and scripts needed. The user then takes the species prefab and merges it with the desired creature prefab (model, animator, camera, etc), the component connections are corrected, and when finished the user saves the merged result as a new prefab. The latest prefab can then be instantiated whenever, where ever. An AI manager tracks all species and associated instantiations and updates them accordingly.
I am not sure what the best way of coding this system would be. I’ve looked into enums, switches, coroutines, overloading, delegates, Generics, namespaces, and polymorphism.
What combination of structures would work best? I’m focused on optimization rather than simplicity.