Esempio n. 1
0
/**
 * @brief Store an episodic memory about the self
 * @param local_sim Pointer to the simulation object
 * @param local Pointer to the being
 * @param event The type of event
 * @param affect An affect value associated with the event
 * @param arg Any additional argument
 */
void episodic_self(
    noble_being * local,
    being_episodic_event_type event,
    AFFECT_TYPE affect,
    n_byte2 arg)
{
    episodic_store_memory(local, event, affect,
                          being_gender_name(local), being_family_name(local),
                          0, 0, arg);
}
Esempio n. 2
0
void episodic_self(
                   noble_simulation * local_sim,
                   noble_being * local,
                   n_byte event,
                   n_int affect,
                   n_byte2 arg)
{
    episodic_store_memory(local, event, affect, local_sim,
                          GET_NAME_GENDER(local_sim,local),GET_NAME_FAMILY2(local_sim,local),
                          0, 0, arg);
}
Esempio n. 3
0
/**
 * @brief Remember a particular interaction between two beings
 * @param local_sim Pointer to the simulation object
 * @param local Pointer to the being
 * @param other Pointer to the being being interacted with
 * @param event The type of event
 * @param affect The affect associated with the interaction
 * @param arg Any additional argument
 */
void episodic_interaction(
    noble_being * local,
    noble_being * other,
    being_episodic_event_type event,
    AFFECT_TYPE affect,
    n_byte2 arg)
{
    episodic_store_memory(
        local, event, affect,
        being_gender_name(local),being_family_name(local),
        being_gender_name(other),being_family_name(other), arg);
}
Esempio n. 4
0
/**
 * @brief Updates the sex drive
 * @param local Pointer to the ape
 * @param awake whether the ape is awake
 * @param local_sim Pointer to the simulation
 */
static void drives_sex(
    noble_being * local,
    n_int awake,
    noble_simulation * local_sim)
{
    n_int i,max;
    noble_social * local_social_graph = being_social(local);
    n_int age_in_days = AGE_IN_DAYS(local);

#ifdef EPISODIC_ON
    noble_episodic * local_episodic = being_episodic(local);
#endif

    /** is the being mature */
    if (age_in_days > AGE_OF_MATURITY)
    {
        /** is the being awake and its sex drive not saturated */
        if (awake)
        {
            /** increase the sex drive */
            being_inc_drive(local, DRIVE_SEX);

            /** if sex drive is above a mate seeking threshold and
            the being has no current goal */
            if ((being_drive(local, DRIVE_SEX) > THRESHOLD_SEEK_MATE) &&
                being_check_goal(local, GOAL_NONE))
            {
                /** either search for a preferred mate, or mate randomly */
                if (GENE_MATE_SEEK(being_genetics(local))&1)
                {
                    /** look for a mate */
#ifdef EPISODIC_ON
                    if (!local_episodic) return;

                    /** does the being remember mating in the recent past */
                    for(i=0; i<EPISODIC_SIZE; i++)
                    {
                        if (local_episodic[i].event == EVENT_MATE)
                        {
                            /** not someone else's mate */

                            if (being_name_comparison(local, local_episodic[i].first_name[BEING_MEETER], local_episodic[i].family_name[BEING_MEETER]))
                            {
                                /** set a goal to seek the remembered mate */
                                
                                being_set_goal_mate(local, local_episodic[i].first_name[BEING_MET], local_episodic[i].family_name[BEING_MET]);
                                
                                /** remember seeking a mate */
                                episodic_store_memory(
                                    local_sim,
                                    local, EVENT_SEEK_MATE, AFFECT_SEEK_MATE,
                                    being_gender_name(local), being_family_name(local),
                                    local->delta.goal[1], local->delta.goal[2],0);
                                break;
                            }
                        }
                    }
#endif
                    /** if the being is not seeking a remembered mate
                        then examine the social graph for attractive prospects */
                    if (being_check_goal(local, GOAL_MATE) == 0)
                    {
                        max = 0;
                        if (!local_social_graph) return;

                        for(i=1; i<SOCIAL_SIZE_BEINGS; i++)
                        {
                            if (!SOCIAL_GRAPH_ENTRY_EMPTY(local_social_graph,i))
                            {
                                if ((local_social_graph[i].attraction) > max)
                                {
                                    
                                    /** who are we most attracted to? */
                                    max=local_social_graph[i].attraction;
                                    
                                    being_set_goal_mate(local, local_social_graph[i].first_name[BEING_MET], local_social_graph[i].family_name[BEING_MET]);
                                }
                            }
                        }
                        /** if an attractive mate was found then remember this event */
                        if (being_check_goal(local, GOAL_MATE))
                        {
                            episodic_store_memory(
                                local_sim,
                                local, EVENT_SEEK_MATE, AFFECT_SEEK_MATE,
                                being_gender_name(local), being_family_name(local),
                                local->delta.goal[1], local->delta.goal[2],0);
                        }
                    }
                }
            }
            /** during gestation reduce the sex drive */
            if (being_pregnant(local) != 0)
            {
                if (being_drive(local, DRIVE_SEX) >= GESTATION_SEX_DRIVE_DECREMENT)
                {
                    being_dec_drive(local, DRIVE_SEX);
                }
            }
        }
        else
        {
            /** while sleeping reduce sex drive */
            being_dec_drive(local, DRIVE_SEX);
        }
        /** if sex drive falls below the mate seeking threshold and the being
            is seeking a mate, then stop seeking a mate */
        if ((being_drive(local, DRIVE_SEX) < THRESHOLD_SEEK_MATE) &&
             being_check_goal(local, GOAL_MATE))
        {
            being_set_goal_none(local);
        }
    }
}