Difference between revisions of "Brains"

From Forge Community Wiki
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Under construction}}
 
{{Under construction}}
  
Brains were introduced in 1.14 (Village & Pillage) as an alternative to Goals and Targets, for use by the updated Villagers. Since then, all new mobs have been implemented using brains.
+
Brains were introduced in 1.14 (Village & Pillage) as an alternative to Goals and Targets, for use by the updated Villagers. Since then, almost all new mobs (exceptions: bees & striders) have been implemented using brains.
  
 
== Sensors ==
 
== Sensors ==
Sensors are used to collect information about the entity’s world. This is where things like entity searches and block searches should be performed. After a specified amount of ticks, any search logic will run and store relevant information in the entity’s Brain using Memory Modules.
+
Sensors are used to collect information about the entity’s world. This is where things like entity searches and block searches should be performed. After a specified amount of ticks (if not specified, it defaults to 20), any search logic will run and store relevant information in the entity’s Brain using Memory Modules.
  
 
== Memory Modules ==
 
== Memory Modules ==
Memory Modules are used to store state in the entity's Brain. They are also used as entry conditions for Activities and Behaviors, with the presence or absence of a memory functioning very similar to Flags used by Goals. Some Memory Modules have Codecs which allow the state they hold to be written to and loaded from disk.
+
Memory Modules are used to store state in the entity's Brain. They are also used as entry conditions for Activities and Behaviors, with the presence or absence of a memory functioning very similar to Flags used by Goals. Some Memory Modules have Codecs which allow the state they hold to be written to and loaded from disk. This can be used as a "long-term" memory for an entity, such as the UUID of an enemy that angered it.
  
 
== Behaviors ==
 
== Behaviors ==
Behaviors are Brain's equivalent of Goals, constructed using a map of MemoryModuleTypes to MemoryStatus that dictates whether or not the Behavior can start executing based on the presence or absence of specific Memory Modules. The equivalent to this in Goals is the Flags passed in to the "setFlags" method.
+
Behaviors are Brain's equivalent of Goals, constructed using a map of MemoryModuleTypes to MemoryStatus. This map functions as an "entry condition" that dictates whether or not the Behavior can start executing based on the presence or absence of specific Memory Modules. The equivalent to this in Goals is the Set of Flags passed in to the "setFlags" method during the Goal's construction.
  
 
They can also be given a min and/or max runtime duration in ticks, automatically terminating at a timestamp randomly determined by the supplied runtime duration value(s). The "checkExtraStartConditions", "start", "canStillUse", and "stop" methods correspond to Goal's "canUse", "start", "canContinueToUse" and "stop" methods, respectively.
 
They can also be given a min and/or max runtime duration in ticks, automatically terminating at a timestamp randomly determined by the supplied runtime duration value(s). The "checkExtraStartConditions", "start", "canStillUse", and "stop" methods correspond to Goal's "canUse", "start", "canContinueToUse" and "stop" methods, respectively.
  
 
== Activities ==
 
== Activities ==
Activities are used to differentiate sets of Behaviors to allow for further complexity of an entity's AI. An Activity can be added to a Brain along with the Behaviors it contains, as well as the Memory Module entry conditions for the Activity and any Memory Modules that should be erased upon termination of the Activity.
+
Activities are used to differentiate sets of Behaviors to allow for further complexity of an entity's AI. An Activity can be added to a Brain along with a collection of Behaviors it controls, as well as the Memory Module entry conditions for the Activity and any Memory Modules that should be erased upon termination of the Activity.

Latest revision as of 02:36, 30 March 2023

This page is under construction.

This page is incomplete, and needs more work. Feel free to edit and improve this page!

Brains were introduced in 1.14 (Village & Pillage) as an alternative to Goals and Targets, for use by the updated Villagers. Since then, almost all new mobs (exceptions: bees & striders) have been implemented using brains.

Sensors

Sensors are used to collect information about the entity’s world. This is where things like entity searches and block searches should be performed. After a specified amount of ticks (if not specified, it defaults to 20), any search logic will run and store relevant information in the entity’s Brain using Memory Modules.

Memory Modules

Memory Modules are used to store state in the entity's Brain. They are also used as entry conditions for Activities and Behaviors, with the presence or absence of a memory functioning very similar to Flags used by Goals. Some Memory Modules have Codecs which allow the state they hold to be written to and loaded from disk. This can be used as a "long-term" memory for an entity, such as the UUID of an enemy that angered it.

Behaviors

Behaviors are Brain's equivalent of Goals, constructed using a map of MemoryModuleTypes to MemoryStatus. This map functions as an "entry condition" that dictates whether or not the Behavior can start executing based on the presence or absence of specific Memory Modules. The equivalent to this in Goals is the Set of Flags passed in to the "setFlags" method during the Goal's construction.

They can also be given a min and/or max runtime duration in ticks, automatically terminating at a timestamp randomly determined by the supplied runtime duration value(s). The "checkExtraStartConditions", "start", "canStillUse", and "stop" methods correspond to Goal's "canUse", "start", "canContinueToUse" and "stop" methods, respectively.

Activities

Activities are used to differentiate sets of Behaviors to allow for further complexity of an entity's AI. An Activity can be added to a Brain along with a collection of Behaviors it controls, as well as the Memory Module entry conditions for the Activity and any Memory Modules that should be erased upon termination of the Activity.