AI System

From Sons of the Forest Wiki
Jump to navigation Jump to search
Cannibal using pathfinding techniques to complete their tasks in the most efficient manner possible.

In Sons of the Forest, the artificial intelligence system for each living entity is designed to provide a dynamic and evolving experience for players. This is achieved through a set of cognitive capabilities known as "thoughts," which generate paths for each entity based on a variety of variables that adapt and evolve in response to the player's actions and decisions. To achieve this level of complexity, the game's AI system uses a ruled-based modeling approach, which allows for the pre-programming of specific rules and constraints that guide the entities behavior. Each entity within the game is categorized based on their name, emotions, fear, anger, and energy levels which significantly influence their interactions with the player.

Although this type of information may not be visible to the player, it plays a crucial role in comprehending the game's artificial intelligence system. By leveraging ruled-based modeling, the Developers are able to create a rich and immersive experience that provides players with a dynamic and evolving gameplay experience.

Entities[edit | edit source]

Name[edit | edit source]

In most cases, an entity's name corresponds to its model or characteristics. For example, Moose, Turtle, MuddyMale, and MuddyFemale are simple names used to identify entities lacking complex features. However, the naming for regular Cannibals differs, as they may be referred to as Carl, Andy, Angel, Billy, Danny, Brandy, Crystal, or Destiny. The origin behind those names remains unknown.

Sentiment[edit | edit source]

Example of Sentiment with Cannibal

Sentiment plays a crucial role in Sons of the Forest, it's influencing how the Cannibal AI remembers past interactions with the player. The only way of decreasing sentiment towards the player amongst entities involves causing them damages through any means possible. If a Cannibal endures severe injuries and remains alive, its negative sentiment towards the player will persist for an extended duration. Notably, entities such as the Golden Mask Cannibal maintain their sentiment towards the player, even if they are subjected to attack from the player. While the full extent of sentiment's effects remains uncertain, it currently serves no practical purpose within the game. However, there is a possibility that the developers will allow players to establish friendly relationships with certain Cannibals or tributes in the future. As of now, sentiment levels will only increase if interacting with Kelvin or Virginia.

The sentiment level of Kelvin gradually increases by approximately 0.1 every seven seconds when in proximity to the player.
The sentiment level of Virginia gradually increases by approximately 0.1 every seven seconds when in proximity to the player.

Fear[edit | edit source]

Example of Fear with Cannibal

When (Fear value) ≥ (Anger value) it prompts entities to flee from a player. E.g. a cannibal with 100 anger will not flee in fright until it gets 100 fear. Fear levels can be increased by effigies, taunting with equipped skulls/heads, causing damage, and gunshots.

Player-influenced fear can be interpreted as a rational behaviour which varies from different entities. For instance, Dirty cannibal normally begins with 30 of fears, in contrast to a normal Cannibal who starts at 0.

The best way to comprehend fear is by comparing it to human stress during a fight. The fear level of a Cannibal, for instance, may start at around 20 during a fight, but can quickly increase to 100 if it gets hit. During such situations, fear levels tend to fluctuate frequently, rising and falling in response to changing circumstances.

To see debug information regarding fear and anger use the command "aishowstats on".

Anger[edit | edit source]

Example of normal anger with Cannibal

The most influential variable among the bunch is anger, which directly affects entities within the game. Essentially, anger represents the probability of a cannibal attacking the player. Although this variable is not fully understood, it is established that the initial anger level of cannibals at the start of a game is 10 towards the player, which increases based on the player's actions throughout the game. Actions such as destroying villages, killing cannibals, being in a village camp, being in close proximity to cannibals, cutting trees, and shooting either at cannibals or in general can all contribute to an increase in the anger level. Once it reaches 100, cannibals will exhibit aggressive behavior and will actively pursue and attack the player. As of now, there is no way to decrease this variable. Consequently, players cannot maintain peaceful relationships with any clans or cannibals.


The game employs three types of anger levels, which are player-influenced, environment-influenced and anger in general. The former is determined by the actions of the player, while the latter is determined by various environmental factors, such as the presence of enemies or perceived threats. These anger levels are known to fluctuate frequently, rising and falling in response to changing circumstances. Regarding the general aggression level of cannibals throughout the game, it is determined by the number of cannibals killed by the player and the current day in-game. However, there are certain methods, such as utilizing molotovs or bombs, that do not directly contribute to the increase of this variable. As the aggression level increases, so too does their armor rating. Consequently, it is imperative to consider their impact on entity behavior while playing the game.


In the most recent update, the developers have calibrate anger levels for certain entities of the muddies cannibal. It appears that the anger levels for this entity have been reduced from 10 to 6, resulting in a decrease in their level of aggression. In the foreseeable future, we anticipate that such changes to entities behavior may become more frequent. As a result, we plan to make a board to monitored all entities when it will be necessary.

Energy[edit | edit source]

Energy can be considered as a variable that is shared between the player and other entities in the game. This parameter is crucial in providing a realistic experience for the entities, as it introduces a sense of vulnerability and limits their endurance, similar to that of the player. With each movement, an entity loses 0.1 units of energy. However, certain entities such as the golden cannibal may deplete their energy reserves at a faster rate, especially when charging at the player. Depending on the type of attack, the energy loss for an entity can range from 2-3 units for a slash, to 6-9 units for a powerful strike.

Kelvin cutting a tree with his energy levels depleting rapidly.

In addition, Kelvin, one of your companions in the game, is also affected by this variable. His ability to perform tasks and assist the player is directly impacted by his energy levels. For instance, cutting down tree in quick succession can cause him to lose up to one energy level per second. Once he has finished the task, Kelvin will take a break and rest to gain energy levels. Despite Kelvin having a limited amount of energy, he is capable of continuing to perform tasks even when his energy levels have been depleted to zero.

Kelvin resting to increase his energy.


Memory[edit | edit source]

Example of memory with Cannibal

Memory is an important component of an entity's decision-making process because it enable entity to recall past actions. However, not all interactions and events can be stored in memory, as it would require significant computational resources. Instead, only important events and interactions that have a significant impact on the entity's behavior are recorded and retained in memory. This includes fighting regular cannibal, fighting muddies, fighting Creepies, hunting animals, getting sticks and firearm usage by the player.

Each entity's memory value decreases by 0.01 every 3 seconds, which means that the impact of past events and interactions on an entity's behavior decreases over time. However, the memory value will stops decreasing once it reaches a certain threshold, which depends on the frequency and intensity of the observed actions of the player. For instance, when a player attacks a village and engages in combat with a member of a cannibal family, the event is recorded in the memory of the entire family and influences their behavior towards the player. It is important to note that if the player fights a certain type of cannibal close to other types of cannibals, this event will be recorded in their memory and will have a lasting impact on their behavior.

A point to note is that Cannibals in the game will not remember if you spare them or their injured family members. However, they can retain other values such as fear and sentiment towards the player. It's important to consider that these entities are not capable of complex emotions or thought processes beyond what is programmed into their AI. So, while they may exhibit certain behaviors and responses, they do not have true memory or consciousness like a human being.

Stats[edit | edit source]

Billystats.png
Seastats.png

The variables referred to as "stats" are integral to the behavior of all entities. However, the current implementation of this variable is incomplete and requires further refinement from the developer as it has little impact on their behavior. As of now, Entities are not penalize for having low values for their stats. The statistics are categorized into three main components: fullness, hydration, and energy.

Fullness will varies depending on the entity's food intake. For example, cannibals exhibit little to no fullness and rely on consuming body parts to replenish their fullness levels rapidly. Although they seem to exhibit hunting behavior, it has yet to be observed in action. In contrast, animals such as birds display more apparent fullness behavior, as they actively seek out sources of food and water. The seagull is a notable example of this, as it will land to consume something on the ground, even though it cannot be interacted with. Fullness levels decrease by 0.1 for every entity every 2-3 seconds.

Hydration levels are essential to the survival of all entities and can be replenished by consuming any available source of water, including cave water for the blind mutants. Hydration may become more apparent in the future as it has the potential to significantly impact the behavior of entities if not consumed. Currently, however, it is not a requirement for entities to consume water and does not have a significant impact on their behavior. While cannibals may occasionally be observed consuming water from a nearby body of water, it is not a priority for them. As of now, hydration levels decrease by 0.1 approximately every 0.7 seconds.

Status[edit | edit source]

Each entity within the game has a permanent status that communicates its current actions to the game in real-time. These status are categorized based on their specific meanings, which can vary depending on the entity's current situation. The following are all of the possible status:

Thoughts[edit | edit source]

In AI, thoughts are essentially programmed decision-making processes that determine an entity's behavior in response to various environmental factors. In other word, They are essentially set of rules or instructions that the AI of entity will follow for their next action(those rules are designed to be flexible). Since there are numerous factors that can influence an entity's behavior, there are countless thoughts that can occur. These thoughts are often programmed with a degree of randomness, to make the entity's behavior appear more natural and unpredictable.

Full List[edit | edit source]

To facilitate a comprehensive understanding, I will make a list of all thoughts an entity may possess by their status:

Exploring/interacting world
Taunt Captured! What was that noise? Rest a bit Explore the world Heard something near Loud sound! Go check it out
Check my hut Startled by loud noise Idle fidget I should explore the world Someone is right near me Mourn [name]!
Pray a bit Mourn my Dying LOVE! Flee from noise Go to Drink Water Move to forest Run from enemy!
I heard something close What was that sound? Eat my friend [name] Run, very close sound! Run away from enemy! I should get outta here
Sit by fire Throw that body Hit by projectile Land I need some time alone I should bash this [name] head
Go back to base I'm hurt Time to sleep Enjoy the view. Search for water Hide against wall Drink water
Explore the area Hit by melee Create a nest Follow [baby] I'm bored Just standing arround
Waiting for interaction Waiting for note Pickup sticks Drop sticks Search party move Wait to see if enemy appear
I should fight Waiting by Player Hide crouched Follow Player Flee From LocalPlayer Eat Food
Shelter at hut Cower in fear Go to food SeveredArmsPickup Taunt the muddy SeveredHeadPickup
I'd check if this [name] is ?alive? Flee from Cannibal ouch I got hit Go Hunt as Group Pray to mask man Head Home
Step curious to mask I should eat food Steal that log Bash this structure Climb reaction Hit the muddy!
Taunt [Name] Search for lost enemy Rub my feet Go to food Go to water Dance on tree
Wash in water. Laugh with player Player is stopping me. I like that, thumb up Drop items Eat [Name]
Wash in a waterfall. Get Player to follow me Lead Player Dance to this music Grab a radio Follow player with radio
LocalPlayer is too close. Lound sound! Flee area Move near player Move away from player Gather some berries Search this bush


Combat
I see an enemy to fight Jump onto rock Jump off rock I like to watch crouch Step curious toward enemy Run back from target !
Idle watch Approach enemy Step back slowly Taunt [Name] Jump onto Tree Jump off Tree
Run to Flank target Flank target Circle LocalPlayer walk to Flank target Leave Search area Back away from enemy
Anticipate dodge Attack react Walk flank back Combo Attack React Big Taunt LocalPlayer Move to Attack
Gun run! Throw that body Run kick LocalPlayer I'm drowning Too far from trees!! Flee the area scared!
Run attack LocalPlayer Jump attack off rock Move closer to ATTACK Jump attack LocalPlayer ne? Hide behind a tree Argghhh I tripped
Threaten LocalPlayer Throw rock at LocalPlayer I should fight I should run back Run attack in out I should combo attack
To attack Localplayer from behind? Move to last sighted point Im feeling better now ee? scared from LocalPlayer Run kick Robby Alert others I saw someone?!
Run from [name]! Lunge attack LocalPlayer Taunt Robby Threaten? LocalPlayer to stay ?away Run attack Robby Distracted by food
Ouch I got hit Dodge and counter Flee Scared from LocalPlayer I like to watch Step back slowly Watch enemy
Back Away Point at [Name] Cower in fear Block PlayerMeleeAttack Block ancitipate Watch enemy far
I should fire at enemy Move away from enemy Aim weapon at [Name] Back away quickly Run behind a tree Point at this enemy
Pistol shot this guy! Shotgun this fool! Attack from tree Block to counter - -
Dying/Dead
Im dead Oops I died radgoll I should crawl back I'm dead an limp.
Flying
Explore the area Fly near player Find food and land Flee from soft noise I should land Flee from noise Eat this while flying
Hover Dart Circling arround that Flee medium noise I should go fly around Explore the world Fly away to sleep
On rock
Watch LocalPlayer Ouch I was Attacked! Jump out at enemy
On Tree
Hang out in tree Jump off tree Taunt LocalPlayer Jump to new tree
UnderLeaves
Jump out by [Name] Ouch I was Attacked! Jump out at enemy
Injured
Just staying here. Flee area, I'm injured! Flee from LocalPlayer Im so tired Should enter injured states

Behavior[edit | edit source]

Each entity exhibits a unique and distinct behavior. To gain insight into those behaviors, understanding and analyzing their patterns is necessary. In the following section, a comprehensive presentation of each entity present in the game will be provided, along with a detailed analysis of their observed behaviors in-game:

TBA

Turtle[edit | edit source]

The reptilian entities tend to remain in offshore with occasional forays onto land for purposes such as exploration or laying eggs. Their behavior is relatively simple, lacking complexity and they do not display any signs of attempting to seek food or water. Furthermore, they appear to be free from predation by Cannibal entities. It is worth noting that when their eggs hatch, baby turtles emerge which cannot be interacted with or harmed in any way, and thus, do not qualify as a separate entity.