Noble Ape
The Central Directories of the Noble Ape Simulation.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Enumerations | Functions
entity_internal.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  being_nearest

Macros

#define CONSUME_E(being, max_energy, food)
#define OFFSET_GRASS   40
#define OFFSET_BUSH   14

Enumerations

enum  sleep_state { FULLY_ASLEEP = 0, SLIGHTLY_AWAKE = 1, FULLY_AWAKE = 2 }

Functions

void body_genetics (noble_being *beings, n_int number, n_genetics *genetics, n_genetics *mother_genetics, n_genetics *father_genetics, n_byte2 *local)
n_int food_eat (n_land *local_land, n_int loc_x, n_int loc_y, n_int az, n_byte *food_type, noble_being *local_being)
 Eat food at the given location and return the energy increase.
n_int food_absorption (noble_being *local, n_int max_energy, n_byte food_type)
 How much energy is absorbed from a given type of food.
void food_values (n_land *local_land, n_int loc_x, n_int loc_y, n_int *grass, n_int *trees, n_int *bush)
 Returns the values for grass, trees and bushes at the given location.
n_int genetics_compare (n_genetics *genetics_a, n_genetics *genetics_b)
 Compares two genetics and returns 1 if they are the same.
void genetics_set (n_genetics *genetics_a, n_genetics *n_genetics)
 Sets genetics A to be the same as genetics B.
void genetics_zero (n_genetics *genetics_a)
 Creates a blank genome.
void metabolism_init (noble_being *local_being)
void metabolism_cycle (noble_simulation *local_sim, noble_being *local_being)
void metabolism_vascular_response (noble_simulation *local_sim, noble_being *local_being, n_int response)
void metabolism_eat (noble_being *local_being, n_byte food_type)
void metabolism_suckle (noble_simulation *sim, noble_being *child, noble_being *mother)
void social_action (noble_simulation *sim, noble_being *meeter_being, noble_being *met_being, n_byte action)
 Performs a given action.
n_int social_network (noble_being *meeter_being, noble_being *met_being, n_int distance, noble_simulation *sim)
 When two apes meet within a given maximum range this updates the social graph of both.
n_int social_set_relationship (noble_being *meeter_being, n_byte relationship, noble_being *met_being, noble_simulation *sim)
 Set the relationship type between two apes.
n_int social_get_relationship (noble_being *meeter_being, n_byte relationship, noble_simulation *sim)
 Returns the social graph index of the given relationship type. This can be used for example to search for the father of an ape within the social graph.
n_byte social_groom (noble_being *meeter_being, noble_being *met_being, n_int distance, n_int awake, n_byte2 familiarity, noble_simulation *sim)
 Grooming behavior.
n_byte2 social_squabble (noble_being *meeter_being, noble_being *met_being, n_uint distance, n_int is_female, noble_simulation *sim)
 Squabbling and fighting.
n_int social_mate (noble_being *meeter_being, noble_being *met_being, n_int being_index, n_int distance, noble_simulation *sim)
 Mating behavior.
n_int social_chat (noble_being *meeter_being, noble_being *met_being, n_int being_index, noble_simulation *sim)
 Dialogue between beings.
void social_goals (noble_being *local)
 Goal oriented behavior.
n_int get_noble_social (noble_being *meeter_being, noble_being *met_being, noble_simulation *sim)
 If two beings have previously met return the social graph index.
n_int episodic_met_being_celebrity (noble_simulation *local_sim, noble_being *meeter_being, noble_being *met_being)
 Returns a celebrity factor based upon how many apes within the episodic memory of the given ape have a similar name to the met ape, and their friend or foe values. This means that initial beliefs about other apes are partly a form of stereotyping.
void episodic_store_memory (noble_being *local, n_byte event, n_int affect, noble_simulation *local_sim, n_byte2 name1, n_byte2 family1, n_byte2 name2, n_byte2 family2, n_byte2 arg)
 Updates the episodic memory with details about an event.
void episodic_food (noble_simulation *local_sim, noble_being *local, n_int energy, n_byte food_type)
 Remember eating.
void episodic_self (noble_simulation *local_sim, noble_being *local, n_byte event, n_int affect, n_byte2 arg)
 Store an episodic memory about the self.
void episodic_close (noble_simulation *local_sim, noble_being *local, noble_being *other, n_byte event, n_int affect, n_byte2 arg)
 Remember an event which occurred between being in close proximity.
void episodic_interaction (noble_simulation *local_sim, noble_being *local, noble_being *other, n_byte event, n_int affect, n_byte2 arg)
 Remember a particular interaction between two beings.
n_byte episodic_intention (noble_simulation *local_sim, noble_being *local, n_int episode_index, n_byte2 mins_ahead, n_byte args)
 Generate an intention. Note that intentions are stored together with episodic memories, with the event type making the difference between a memory about the past and an intention about the future.
n_byte episodic_anecdote (noble_simulation *local_sim, noble_being *local, noble_being *other)
 Copy an episodic memory (an anecdote) from one ape to another during chat.
void being_init_braincode (noble_being *local, noble_being *other, n_byte friend_foe, n_byte internal)
n_byte get_braincode_instruction (noble_being *local_being)
 returns a random braincode instruction
void being_ingest_pathogen (noble_being *local, n_byte food_type)

Macro Definition Documentation

#define CONSUME_E (   being,
  max_energy,
  food 
)

Definition at line 46 of file entity_internal.h.

#define OFFSET_BUSH   14

Definition at line 50 of file entity_internal.h.

#define OFFSET_GRASS   40

Definition at line 49 of file entity_internal.h.


Enumeration Type Documentation

Enumerator:
FULLY_ASLEEP 
SLIGHTLY_AWAKE 
FULLY_AWAKE 

Definition at line 39 of file entity_internal.h.


Function Documentation

void being_ingest_pathogen ( noble_being local,
n_byte  food_type 
)

Definition at line 910 of file being.c.

Here is the caller graph for this function:

void being_init_braincode ( noble_being local,
noble_being other,
n_byte  friend_foe,
n_byte  internal 
)

initialise inner or outer braincode

initially seed the brain with instructions which are random but genetically biased

initialise based upon a similar being

Find the entry in the social graph with the most similar friend or foe value. The FOF value is used because when two beings meet for the first time this value is calculated based upon a variety of genetic and learned dispositions. Notice also that the search includes index zero, which is the self.

Copy braincode for the most similar individual

Definition at line 3084 of file being.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void body_genetics ( noble_being beings,
n_int  number,
n_genetics genetics,
n_genetics mother_genetics,
n_genetics father_genetics,
n_byte2 local 
)

crossover and mutation

Y chromosome does not undergo crossover and passes from father to son

transpose genes between chromosomes

align the sex genetics

Definition at line 911 of file body.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_byte episodic_anecdote ( noble_simulation local_sim,
noble_being local,
noble_being other 
)

Copy an episodic memory (an anecdote) from one ape to another during chat.

Parameters:
local_simPointer to the simulation
localPointer to the ape conveying the anecdote
otherPointer to the ape to which the anecdote will be copied
Returns:
Returns 1 if the copy was successful, 0 otherwise

both protagonists must be awake

more likely to make errors while drowsy

mutate with some probability

affect gets exaggerated or downplayed

keep affect within range

find an index within the other episodic memory in which to insert

other ape pays attention to the incoming anecdote

Definition at line 684 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void episodic_close ( noble_simulation local_sim,
noble_being local,
noble_being other,
n_byte  event,
n_int  affect,
n_byte2  arg 
)

Remember an event which occurred between being in close proximity.

Parameters:
local_simPointer to the simulation object
localPointer to the first being
otherPointer to the second being
eventThe type of event
affectAffect value associated with the event
argAny additional argument

Definition at line 556 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void episodic_food ( noble_simulation local_sim,
noble_being local,
n_int  energy,
n_byte  food_type 
)

Remember eating.

Parameters:
local_simPointer to the simulation object
localPointer to the being
energyEnergy obtained from food
food_typeThe type of food

Definition at line 498 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_byte episodic_intention ( noble_simulation local_sim,
noble_being local,
n_int  episode_index,
n_byte2  mins_ahead,
n_byte  args 
)

Generate an intention. Note that intentions are stored together with episodic memories, with the event type making the difference between a memory about the past and an intention about the future.

Parameters:
local_simPointer to the simulation
localPointer to the ape
episode_indexEpisodic memory array index to use.
mins_aheadThe number of minutes into the future for which the intention will last.
argsAny additional arguments
Returns:
Returns 1 if the update was successful, or 0 otherwise.

increment date by one day

extend the time of an existing intention

if this was someone else's intention it now becomes yours

only certain types of events become intentions

find a memory index to replace

Definition at line 604 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void episodic_interaction ( noble_simulation local_sim,
noble_being local,
noble_being other,
n_byte  event,
n_int  affect,
n_byte2  arg 
)

Remember a particular interaction between two beings.

Parameters:
local_simPointer to the simulation object
localPointer to the being
otherPointer to the being being interacted with
eventThe type of event
affectThe affect associated with the interaction
argAny additional argument

Definition at line 578 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_int episodic_met_being_celebrity ( noble_simulation local_sim,
noble_being meeter_being,
noble_being met_being 
)

Returns a celebrity factor based upon how many apes within the episodic memory of the given ape have a similar name to the met ape, and their friend or foe values. This means that initial beliefs about other apes are partly a form of stereotyping.

Parameters:
local_simpointer to the simulation
meeter_beingpointer to the ape
met_beingpointer to another ape
Returns:
celebrity value of the met ape

check all episodic memories of the meeter

check both the meeter and the met ape for each memory

same first name

same family name

if both first name and family name match then increase the celebrity value further

limit within range

Definition at line 207 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void episodic_self ( noble_simulation local_sim,
noble_being local,
n_byte  event,
n_int  affect,
n_byte2  arg 
)

Store an episodic memory about the self.

Parameters:
local_simPointer to the simulation object
localPointer to the being
eventThe type of event
affectAn affect value associated with the event
argAny additional argument

Definition at line 536 of file episodic.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void episodic_store_memory ( noble_being local,
n_byte  event,
n_int  affect,
noble_simulation local_sim,
n_byte2  name1,
n_byte2  family1,
n_byte2  name2,
n_byte2  family2,
n_byte2  arg 
)

Updates the episodic memory with details about an event.

Parameters:
localPointer to the ape
eventThe type of event
affectThe affect value associated with the event
local_simPointer to the simulation
name1Name of the first ape in the memory (meeter)
family1Family name of the first ape in the memory (meeter)
name2Name of the second ape in the memory (met)
family2Family name of the second ape in the memory (met)
argAny additional arguments

Definition at line 517 of file episodic.c.

Here is the caller graph for this function:

n_int food_absorption ( noble_being local,
n_int  max_energy,
n_byte  food_type 
)

How much energy is absorbed from a given type of food.

Parameters:
food_typeThe type of food
localpointer to the ape
Returns:
Energy absorbed

note that the absorbition for different foods is normalised

ingest pathogens from certain foods

< can only eat so much in one go

Definition at line 75 of file food.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_int food_eat ( n_land local_land,
n_int  loc_x,
n_int  loc_y,
n_int  az,
n_byte food_type,
noble_being local_being 
)

Eat food at the given location and return the energy increase.

Parameters:
simPointer to the simulation
loc_xX ape coordinate
loc_yY ape coordinate
azZ ape coordinate
local_beingPointer to the ape
Returns:
Energy obtained from the food

above the high water mark

in the intertidal zone

Definition at line 278 of file food.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void food_values ( n_land local_land,
n_int  loc_x,
n_int  loc_y,
n_int grass,
n_int trees,
n_int bush 
)

Returns the values for grass, trees and bushes at the given location.

Parameters:
local_landPointer to the land
local_weatherPointer to the weather
loc_xX ape coordinate on the map
loc_yY ape coordinate on the lap
grassReturned value for grass
treesReturned value for trees
bushReturned value for bushes

grass at this location

trees at this location

bushes at this location

Definition at line 155 of file food.c.

n_int genetics_compare ( n_genetics genetics_a,
n_genetics genetics_b 
)

Compares two genetics and returns 1 if they are the same.

Parameters:
genetics_aFirst genetics
genetics_bSecond genetics
Returns:
1 if the two genetics are the same, 0 otherwise

Definition at line 611 of file body.c.

void genetics_set ( n_genetics genetics_a,
n_genetics genetics_b 
)

Sets genetics A to be the same as genetics B.

Parameters:
genetics_aThe destination genetics
genetics_bThe source genetics

Definition at line 631 of file body.c.

Here is the caller graph for this function:

void genetics_zero ( n_genetics genetics_a)

Creates a blank genome.

Parameters:
genetics_aThe genetics to be cleared

Definition at line 645 of file body.c.

n_byte get_braincode_instruction ( noble_being local_being)

returns a random braincode instruction

Parameters:
local_beingPointer to the being
Returns:
braincode instruction

Definition at line 570 of file brain.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_int get_noble_social ( noble_being meeter_being,
noble_being met_being,
noble_simulation sim 
)

If two beings have previously met return the social graph index.

Parameters:
meeter_beingPointer to the ape doing the meeting
met_beingPointer to the ape being met
simPointer to the simulation
Returns:
Array index within the social graph of the meeter, -1 if not found

Definition at line 752 of file social.c.

Here is the call graph for this function:

void metabolism_cycle ( noble_simulation local_sim,
noble_being local_being 
)
void metabolism_eat ( noble_being local_being,
n_byte  food_type 
)
void metabolism_init ( noble_being local_being)
void metabolism_suckle ( noble_simulation sim,
noble_being child,
noble_being mother 
)
void metabolism_vascular_response ( noble_simulation local_sim,
noble_being local_being,
n_int  response 
)
void social_action ( noble_simulation sim,
noble_being local,
noble_being other,
n_byte  action 
)

Performs a given action.

Parameters:
simPointer to the simulation object
localPointer to the being performing the action
otherPointer to another being involved in the action
actionThe type of action

individual action

social action

Definition at line 519 of file body.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_int social_chat ( noble_being meeter_being,
noble_being met_being,
n_int  being_index,
noble_simulation sim 
)

Dialogue between beings.

Parameters:
meeter_beingPointer to the being doing the meeting
met_beingPointer to the being which is being met
being_indexArray index for the met individual within the social graph of the meeter
simPointer to the simulation
Returns:
A non-zero value if speaking

agree upon terrirory

do I respect their views ?

pick one of the individuals from their graph

ask about an individual we're searching for

what type of family relationship is currently being attended to

choose randomly

have I already met this individual?

was already met

update this being's belief

belief about location

belief about state

if we have never met then add to my graph as someone I've "heard of". This is like a prior expectation or second hand information. The least familiar relationship is replaced

if this is a family member of the previously unknown being then make sure that the family member type is set to OTHER - i.e. not my family someone else's

initialise the braincode

Definition at line 1601 of file social.c.

Here is the call graph for this function:

n_int social_get_relationship ( noble_being meeter_being,
n_byte  relationship,
noble_simulation sim 
)

Returns the social graph index of the given relationship type. This can be used for example to search for the father of an ape within the social graph.

Parameters:
meeter_beingPointer to the ape
relationshipThe type of relationship to search for
simPointer to the simulation
Returns:
Array index of the social graph for the given type of relationship, -1 if not found

get the social graph

Search the social graph

Is this the desired relationship type?

Definition at line 977 of file social.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void social_goals ( noble_being local)

Goal oriented behavior.

Parameters:
localPointer to the ape
loc_fThe direction facing
Returns:
The new direction facing

move towards a location

are we there yet?

destination reached - goal cancelled

clear any script override

decrement the goal counter

timed out

Definition at line 1765 of file social.c.

Here is the call graph for this function:

Here is the caller graph for this function:

n_byte social_groom ( noble_being meeter_being,
noble_being met_being,
n_int  distance,
n_int  awake,
n_byte2  familiarity,
noble_simulation sim 
)

Grooming behavior.

Parameters:
meeter_beingPointer to the ape doing the meeting
met_beingPointer to the ape being met
distanceDistance between the apes
awakeWhether the met being is awake
familiarityFamiliarity with the met ape
simPointer to the simulation
Returns:
1 if grooming, 0 otherwise

hairy beings can carry more parasites

acquire parasites from the environment with some low probability, and existing parasites multiply

parasites sap energy

hairy beings can carry more parasites

parasite transmission - e.g. flea hop

social grooming removes parasites and alters social status relationships

is the groomee female?

grooming preference

individuals which are familiar tend to groom more often

transmit pathogens via touch

pick a body location to groom

groomed wounds disappear

grooming location becomes the new focus of attention

the two beings meet and become more friendly

Alter social status relations. The groomer gains status, since they are providing a service

Decrement parasites

Definition at line 1075 of file social.c.

Here is the call graph for this function:

n_int social_mate ( noble_being meeter_being,
noble_being met_being,
n_int  being_index,
n_int  distance,
noble_simulation sim 
)

Mating behavior.

Parameters:
meeter_beingPointer to the ape doing the meeting
met_beingPointer to the ape whi is being met
todayThe current date
being_indexArray index for the met individual within the social graph of the meeter
distanceThe Distance between the two apes
simPointer to the simulation
Returns:
The being state: reproducing or not

mating is probabilistic, with a bias towards higher status individuals

attractiveness based upon various criteria

some minimum level of attraction required for pair bonding

transmit pathogens

check opposite sexes

< '=' : conversion from 'n_int' to 'n_byte', possible loss of data

Definition at line 1425 of file social.c.

Here is the call graph for this function:

n_int social_network ( noble_being meeter_being,
noble_being met_being,
n_int  distance,
noble_simulation sim 
)

When two apes meet within a given maximum range this updates the social graph of both.

Parameters:
meeter_beingPointer to the ape doing the meeting
met_beingPointer to the ape being met
distanceDistance between the apes
simPointer to the simulation
Returns:
Array index of the meeter social graph, -1 if not met

Definition at line 1051 of file social.c.

Here is the call graph for this function:

n_int social_set_relationship ( noble_being meeter_being,
n_byte  relationship,
noble_being met_being,
noble_simulation sim 
)

Set the relationship type between two apes.

Parameters:
meeter_beingPointer to the ape doing the meeting
relationshipThe type of relationship
met_beingPointer to the ape being met
simPointer to the simulation
Returns:
Array index of the meeter social graph, -1 if not met

no relationship specified

create the social graph entry if necessary and return its array index

get the social graph

set the relationship type

Definition at line 1013 of file social.c.

Here is the call graph for this function:

n_byte2 social_squabble ( noble_being meeter_being,
noble_being met_being,
n_uint  distance,
n_int  is_female,
noble_simulation sim 
)

Squabbling and fighting.

Parameters:
meeter_beingPointer to the ape doing the meeting
met_beingPointer to the ape being met
distanceDistance between the apes
is_femaleWhether the met being is female
simPointer to the simulation
Returns:
The new being state: showforce/attack

distance between beings

battle with rival families

high ranking apes will more aggressively defend their honor

females are less agressive (less testosterone)

who is the strongest ?

victor disrespects the vanquished

vanquished disrespects the victor

victor increases in honor

vanquished decreases in honor

show of force

attack

remember the fight

vanquished turns away

vanquished flees

Definition at line 1212 of file social.c.

Here is the call graph for this function: