base framework made

This commit is contained in:
2026-03-13 10:02:44 -05:00
parent 4d7bbc33e2
commit 8c86bd2a3e
9 changed files with 288 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
#include "emotional_simulator.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
emotional_state_struct*
alloc_emotional_state(struct emotion_vector_struct initial_base_emotion_vector,
float initial_homeostasis_strength,
float initial_context_weight,
float initial_sentiment_bias,
float initial_volatility)
{
emotional_state_struct* new_emotional_state = calloc(1,
sizeof(emotional_state_struct));
new_emotional_state->base_emotion_vector = initial_base_emotion_vector;
new_emotional_state->homeostasis_strength = initial_homeostasis_strength;
new_emotional_state->context_weight = initial_context_weight;
new_emotional_state->sentiment_bias = initial_sentiment_bias;
new_emotional_state->volatility = initial_volatility;
return new_emotional_state;
}
emotion_vector_struct*
alloc_random_emotion_vector(void)
{
srand((unsigned int)time(NULL)); // seed random number based on time.
emotion_vector_struct* new_emotion_vector = calloc(1,
sizeof(emotion_vector_struct));
for(int i = 0; i < NUMBER_OF_EMOTIONS; i++)
{
new_emotion_vector->values[i] = (emotion_intensity_type)rand() % 256;
}
return new_emotion_vector;
}
void
dump_emotion_vector_values(struct emotion_vector_struct* emotion_vector_to_dump)
{
const char* emotions_names[NUMBER_OF_EMOTIONS] =
{
"admiration\0",
"adoration\0",
"aesthetic_appreciation\0",
"amusement\0",
"anger\0",
"anxiety\0",
"awe\0",
"awkwardness\0",
"boredom\0",
"calmness\0",
"confusion\0",
"craving\0",
"disgust\0",
"empathetic_pain\0",
"entrancement\0",
"excitement\0",
"fear\0",
"horror\0",
"interest\0",
"joy\0",
"nostalgia\0",
"relief\0",
"romance\0",
"sadness\0",
"satisfaction\0",
"sexual_desire\0",
"surprise\0",
};
for(uint8_t i = 0; i < NUMBER_OF_EMOTIONS; i++)
{
puts("=================================================");
printf("| %s: %d\n",
emotions_names[i],
(int)emotion_vector_to_dump->values[i]);
puts("=================================================");
}
}
void
free_emotion_vector(struct emotion_vector_struct* emotion_vector_to_free)
{
free(emotion_vector_to_free);
}
void
free_emotional_state(struct emotional_state_struct* emotional_state_to_free)
{
free(emotional_state_to_free);
}

View File

@@ -0,0 +1,86 @@
#ifndef EMOTIONAL_SIMULATOR_H
#define EMOTIONAL_SIMULATOR_H
#include <stdbool.h>
#include <stdint.h>
#define NUMBER_OF_EMOTIONS 28
typedef uint8_t emotion_intensity_type;
// Used to index into emotion_vectors.
typedef enum emotions_enum
{
admiration = 0,
adoration,
aesthetic_appreciation,
amusement,
anger,
anxiety,
awe,
awkwardness,
boredom,
calmness,
confusion,
craving,
disgust,
empathetic_pain,
entrancement,
excitement,
fear,
horror,
interest,
joy,
nostalgia,
relief,
romance,
sadness,
satisfaction,
sexual_desire,
surprise,
} emotions_enum;
typedef struct emotion_vector_struct
{
emotion_intensity_type values[NUMBER_OF_EMOTIONS];
} emotion_vector_struct;
typedef struct emotional_state_struct
{
bool burnout_flag; // Active if threshold is passed for long.
uint8_t burnout_threshold_countdown; // Which runs while threshold is passed.
uint8_t burnout_threshold; // Threshold for emotion
uint8_t volatility; // The rate at which emotions can change per step.
float context_weight; // How much context influences change.
float sentiment_bias; // Global sentiment modifier.
float homeostasis_strength; // Homeosstatis stat between (0.0 to 1.0)
emotion_vector_struct base_emotion_vector; // The default emotion vector.
emotion_vector_struct current_emotion_vector; // The current emotional state.
emotion_vector_struct* interactor_emotion_vectors;
/* Array of emotional vectors of the interactors in the given context.
* emotional vactors are from the "disposition" one of each tracked for each
* person emrys interacts with. Influenced by interactions over time.
* */
} emotional_state_struct;
emotional_state_struct*
alloc_emotional_state(struct emotion_vector_struct initial_base_emotion_vector,
float initial_context_weight,
float initial_sentiment_bias,
float initial_homeostasis,
float initial_volatility);
emotion_vector_struct*
alloc_random_emotion_vector(void);
void
dump_emotion_vector_values(struct emotion_vector_struct* emotion_vector_to_dump);
void
free_emotional_state(struct emotional_state_struct* emotional_state_to_free);
void
free_emotion_vector(struct emotion_vector_struct* emotion_vector_to_free);
#endif // EMOTIONAL_SIMULATOR_H

View File

@@ -0,0 +1,11 @@
#include "private_emotional_simulator.h"
#include <stdio.h>
#include <stdlib.h>
int
nothing()
{
printf("nothing");
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,11 @@
#ifndef PRIVATE_EMOTIONAL_SIMULATOR_H
#define PRIVATE_EMOTIONAL_SIMULATOR_H
struct placeholder
{
};
int
nothing(void);
#endif // PRIVATE_EMOTIONAL_SIMULATOR_H

12
src/main.c Normal file
View File

@@ -0,0 +1,12 @@
#include "emotional_simulator/emotional_simulator.h"
#include <stdlib.h>
int main(void)
{
emotion_vector_struct *emotion_vector = alloc_random_emotion_vector();
dump_emotion_vector_values(emotion_vector);
free_emotion_vector(emotion_vector);
return EXIT_SUCCESS;
}

0
src/main_test.c Normal file
View File