aifiver

package module
v0.0.0-...-bc5decf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2023 License: GPL-3.0 Imports: 2 Imported by: 6

README

aifiver: Simplified five factor model

This package provides a simplified five factor model (also known as the big five personality traits) for behavioral modeling and whatnot.

I developed this package to somewhat mimic a more "scientific" AI behavior ruleset somewhat akin to Crusader Kings' AI with its very impressive traits and skills system in order to give some realism to the decisions of Kings, Queens, and Tyrants.

It is still very much bare bones right now, but it lays the ground work for my overall vision.

Model variations

There are two variants of the model:

  • A detailed one with all facets and individual weights
  • A simplified one with only the five factors and overall weights

Both provide the same interface, so use whatever floats your boat.

Traits

One can freely define traits that are only expressed by someone who fulfills specified criteria (like minimum or maximum trait scores required).

Examples for traits are:

  • Paranoid
  • Gullable
  • Optimistic
  • Emotional
  • Aggressive
  • etc.

Skills

Skills are more or less how skillful a certain personality is, given their preferences, strengths, and weaknesses.

Skills include:

  • Diplomacy
  • Martial
  • Stewardship
  • Intrigue
  • etc.

Documentation

Overview

Package aifiver implements a simplified representation of the five factor model.

Index

Constants

This section is empty.

Variables

View Source
var (
	ModRecentBetrayal = &Modifier{
		Name: "recent betrayal",
		Factors: [5]int{
			0,
			0,
			0,
			-1,
			1,
		},
		Facets: [30]int{
			0, 0, 0, 0, 0,
			0, 0, 0, 0, 0,
			0, 0, 0, 0, -1,
			-5, -1, 0, 0, 0,
			3, 1, 1, 1, 0,
		},
	}
	ModGriefing = &Modifier{
		Name: "griefing",
		Factors: [5]int{
			0,
			0,
			-1,
			0,
			1,
		},
		Facets: [30]int{
			0, 0, 0, 0, 0,
			0, 0, 0, 0, 0,
			0, 0, 0, 0, -2,
			0, 0, 0, 0, 0,
			0, 1, 2, 0, 0,
		},
	}
	ModSetback = &Modifier{
		Name: "setback",
		Factors: [5]int{
			0,
			1,
			0,
			0,
			1,
		},
		Facets: [30]int{
			0, 0, 0, 0, 0,
			0, 0, 0, 0, 2,
			0, 0, 0, 0, 0,
			0, 0, 0, 0, 0,
			0, 2, 1, 2, 0,
		},
	}
)
View Source
var PresetFool = map[Facet]int{
	FacetOpenFantasy:             8,
	FacetOpenAesthetics:          4,
	FacetOpenFeelings:            6,
	FacetOpenAdventurousness:     4,
	FacetOpenIdeas:               7,
	FacetOpenValues:              6,
	FacetConsCompetence:          0,
	FacetConsOrder:               2,
	FacetConsDutifulness:         -3,
	FacetConsAchievementStriving: -1,
	FacetConsSelfDicipline:       -5,
	FacetConsCautiousness:        -7,
	FacetExtrWarmth:              7,
	FacetExtrGregariousness:      8,
	FacetExtrAssertiveness:       -2,
	FacetExtrActivity:            5,
	FacetExtrExcitementSeeking:   3,
	FacetExtrPositiveEmotions:    7,
	FacetAgreTrust:               8,
	FacetAgreStraightforwardness: -3,
	FacetAgreAltruism:            5,
	FacetAgreCompliance:          8,
	FacetAgreModesty:             6,
	FacetAgreTenderMindedness:    5,
	FacetNeurAnxiety:             3,
	FacetNeurAngryHostility:      -5,
	FacetNeurDepression:          -2,
	FacetNeurSelfConciousness:    5,
	FacetNeurImpulsiveness:       5,
	FacetNeurVulnerability:       4,
}
View Source
var PresetUnstable = map[Facet]int{
	FacetOpenFantasy:             3,
	FacetOpenAesthetics:          4,
	FacetOpenFeelings:            -3,
	FacetOpenAdventurousness:     4,
	FacetOpenIdeas:               -3,
	FacetOpenValues:              -10,
	FacetConsCompetence:          8,
	FacetConsOrder:               7,
	FacetConsDutifulness:         3,
	FacetConsAchievementStriving: 10,
	FacetConsSelfDicipline:       4,
	FacetConsCautiousness:        -4,
	FacetExtrWarmth:              0,
	FacetExtrGregariousness:      3,
	FacetExtrAssertiveness:       9,
	FacetExtrActivity:            5,
	FacetExtrExcitementSeeking:   3,
	FacetExtrPositiveEmotions:    -3,
	FacetAgreTrust:               -5,
	FacetAgreStraightforwardness: -4,
	FacetAgreAltruism:            -4,
	FacetAgreCompliance:          -10,
	FacetAgreModesty:             -10,
	FacetAgreTenderMindedness:    -6,
	FacetNeurAnxiety:             0,
	FacetNeurAngryHostility:      2,
	FacetNeurDepression:          -10,
	FacetNeurSelfConciousness:    -10,
	FacetNeurImpulsiveness:       6,
	FacetNeurVulnerability:       -5,
}

Functions

func Compatibility

func Compatibility(p1, p2 Model) int

Compatibility returns a compatibility value for the given personalities. TODO: Provide function to calculate conflict potential of larger groups. https://github.com/FZarattini/PirateShip/blob/master/PirateShip/Assets/Scripts/AI/Empathy.cs

func DefaultTraits

func DefaultTraits(tt *Traiter)

DefaultTraits adds the default traits to the traiter. These are just examples. If you have suggestions for better traits, please open an issue or a pull request!

func MarkOppositeTraits

func MarkOppositeTraits(a, b *Trait)

MarkOppositeTraits defines two traits as their polar opposite.

Types

type AIMod

type AIMod int

AIMod influences a specific aspect of decision making - AI Boldness - AI Compassion - AI Energy - AI Greed - AI Honor - AI Rationality - AI Sociability - AI Vengefulness

const (
	TAIModBoldness     AIMod = iota // AI Boldness
	TAIModCompassion                // AI Compassion
	TAIModEnergy                    // AI Energy
	TAIModGreed                     // AI Greed
	TAIModHonor                     // AI Honor
	TAIModRationality               // AI Rationality
	TAIModSociability               // AI Sociability
	TAIModVengefulness              // AI Vengefulness
)

func (AIMod) String

func (a AIMod) String() string

String implements the stringer function for an ai modifier.

type BigModel

type BigModel struct {
	Factors [5]int
	Facets  [30]int
}

BigModel represents a more granular five factor model.

func RandomBig

func RandomBig() *BigModel

RandomBig randomizes a big model by distributing half of the total range (-10 to 10 = 20) of each factor and facet randomly. We use a point buy system to distribute the points randomly, however there in reality some factors are more likely to be linked to each other than others. TODO: Find a way to better distribute the points according to the real world.

func (*BigModel) Get

func (p *BigModel) Get(f Factor) int

Get returns the value of the given factor.

func (*BigModel) GetFacet

func (p *BigModel) GetFacet(f Facet) int

GetFacet returns the value of the given facet.

func (*BigModel) Log

func (p *BigModel) Log()

Log logs the big model.

type Facet

type Facet int

Facet represents specific facets within the five factors.

const (
	FacetOpenFantasy             Facet = iota // Proneness to imagination, day-dreaming, and creating
	FacetOpenAesthetics                       // Appreciation for beauty in e.g. art, music, poetry, or nature
	FacetOpenFeelings                         // Receptivity to and intensity of experienced emotions
	FacetOpenAdventurousness                  // The tendency to choose novelty over the familiar
	FacetOpenIdeas                            // The degree of interest and curiosity in entertaining new thoughts and ideas
	FacetOpenValues                           // Willingness to re-evaluate norms and values
	FacetConsCompetence                       // Belief in one's own capacity to handle life's many challenges
	FacetConsOrder                            // Degree of neatness and orderliness
	FacetConsDutifulness                      // How strongly ethical principles guide action
	FacetConsAchievementStriving              // Aspiration-level, the willingness to work towards goals
	FacetConsSelfDicipline                    // The ability to follow through on tasks despite boredom
	FacetConsCautiousness                     // The care and thought put into actions
	FacetExtrWarmth                           // The degree of displayed affection and closeness in relationships
	FacetExtrGregariousness                   // The tendency of seeking the company of others
	FacetExtrAssertiveness                    // The degree of dominance in social interaction
	FacetExtrActivity                         // The level of energy and activity in daily life
	FacetExtrExcitementSeeking                // The need for thrills and intense stimulation
	FacetExtrPositiveEmotions                 // The tendency to be happy, excited, and cheerful
	FacetAgreTrust                            // The general level of wariness or suspicion in contact with other people
	FacetAgreStraightforwardness              // Degree of sincerity vs shrewdness
	FacetAgreAltruism                         // Active concern for the well-being of others
	FacetAgreCompliance                       // Inhibiting vs expressing agression towards others in conflict
	FacetAgreModesty                          // Degree of humility vs arrogance
	FacetAgreTenderMindedness                 // Propensity to empathize with others
	FacetNeurAnxiety                          // Proneness to worry and rumination
	FacetNeurAngryHostility                   // The readiness to experience frustration, anger, and bitterness
	FacetNeurDepression                       // The tendency for guilt, sadness, lonliness, and hopelessness
	FacetNeurSelfConciousness                 // Sensitivity in social situations, such as ridicule, rejection, or awkwardness
	FacetNeurImpulsiveness                    // The ability to tolerate frustration and to control urges, cravings, and desires
	FacetNeurVulnerability                    // The ability to cope with stress
)

The facets.

func (Facet) Factor

func (f Facet) Factor() Factor

Factor returns the factor associated with the given facet.

func (Facet) String

func (f Facet) String() string

String returns the string representation of the facet.

type Factor

type Factor int

Factor represents one of the five factors in the five factor model.

const (
	FactorOpenness Factor = iota
	FactorConscientiousness
	FactorExtraversion
	FactorAgreeableness
	FactorNeuroticism
)

The five factors.

type Fate

type Fate int

Fate that can befall an individual - Early death - Capture in battle - Death in battle - Accidental injury - Bad investment - Scheme fallacy - Scheme discovery

const (
	TFateEarlyDeath      Fate = iota // Early death
	TFateCaptureInBattle             // Capture in battle
	TFateDeathInBattle               // Death in battle
	TFateAccident                    // Accidental injury
	TFateBadInvestment               // Bad investment
	TFateSchemeFallacy               // Scheme fallacy
	TFateSchemeDiscovery             // Scheme discovery
)

func (Fate) String

func (f Fate) String() string

String implements the stringer function for a fate.

type Model

type Model interface {
	Get(factor Factor) int
	GetFacet(facet Facet) int
	Log()
}

Model represents a personality model.

type Modifier

type Modifier struct {
	Name    string  // Name of the modifier
	Factors [5]int  // Modifiers for the five factors
	Facets  [30]int // Modifiers for the 30 facets
}

Modifier is a personality modifier which can be applied to a personality. TODO: - Add persistance to indicate how long this would last. - Should this maybe amplify pre-existing traits instead of simply modifying them? - Should we derive the factor modifiers from the facet modifiers?

type Opinion

type Opinion int

Opinion by type - Same trait - Opposite trait - Attraction

const (
	TOpinionSame       Opinion = iota // Same trait
	TOpinionOpposite                  // Opposite trait
	TOpinionAttraction                // Attraction
)

func (Opinion) String

func (o Opinion) String() string

String implements the stringer function for an opinion.

type Personality

type Personality struct {
	BigModel           // The model which influences which traits are expressed.
	Expressed []*Trait // Traits expressed based on the underlying 5 factor model.
	// TODO: Proneness to fall victim to cetain fates (accidental death, falling victim to intrigue)
	Modifiers []*Modifier // Temporary facet modifiers (Griefing, Recent Betrayal, Setback, ...)
	// contains filtered or unexported fields
}

Personality represents a personality that is a combination of facet scores and expressed traits.

func NewPersonality

func NewPersonality(t *Traiter) *Personality

NewPersonality returns a new, pretty boring personality.

func NewPersonalityFromPreset

func NewPersonalityFromPreset(t *Traiter, ps map[Facet]int) *Personality

NewPersonalityFromPreset returns a new personality based on the given preset.

func NewPersonalityRandomized

func NewPersonalityRandomized(t *Traiter) *Personality

NewPersonalityRandomized returns a new personality with random facet values. TODO: Allow custom rand source or seed.

func (*Personality) AddModifier

func (p *Personality) AddModifier(m *Modifier)

AddModifier adds a modifier to the personality (if it is not already present).

func (*Personality) Get

func (p *Personality) Get(f Factor) int

Get implements the Model interface and applies any modifiers to the base value.

func (*Personality) GetFacet

func (p *Personality) GetFacet(f Facet) int

GetFacet implements the Model interface and applies any modifiers to the base value.

func (*Personality) Interaction

func (p *Personality) Interaction(b *Personality) int

Interaction returns a value for how well the personalities interact face to face.

func (*Personality) Log

func (p *Personality) Log()

Log logs the personality.

func (*Personality) Opinion

func (p *Personality) Opinion(b *Personality) int

Opinion returns the opinion of the other personality based on their reputation. TODO: What about a misperception of the other person?

func (*Personality) Rebuild

func (p *Personality) Rebuild()

Rebuild re-evaluates expressed traits based on the facet ratings.

func (*Personality) RemoveModifier

func (p *Personality) RemoveModifier(m *Modifier)

RemoveModifier removes a modifier from the personality (if it is present).

func (*Personality) Stats

func (p *Personality) Stats() *Stats

Stats returns the stats for the personality.

type Skill

type Skill int

Skill for various aspects

const (
	TSkillDiplomacy Skill = iota // Negotiation
	TSkillMartial                // Tactical skills
	TSkillStewardship
	TSkillIntrigue
	TSkillLearning
	TSkillProwess
	TSkillHealth
	TSkillParenting
)

Various skill types.

func (Skill) String

func (s Skill) String() string

String implements the stringer function for a skill.

type SmallModel

type SmallModel [5]int

SmallModel represents a simplified five factor model. Please note that this is not granular enough to simulate real personalities.

func RandomSmall

func RandomSmall() *SmallModel

RandomSmall randomizes a small model by distributing half of the total range (-10 to 10 = 20) of each factor randomly. We use a point buy system to distribute the points randomly, however there in reality some factors are more likely to be linked to each other than others.

func (*SmallModel) Get

func (p *SmallModel) Get(factor Factor) int

Get returns the value of the given factor.

func (*SmallModel) GetFacet

func (p *SmallModel) GetFacet(facet Facet) int

GetFacet returns the value of the given facet.

func (*SmallModel) Log

func (p *SmallModel) Log()

Log logs the small model.

type Stats

type Stats struct {
	Opinion map[Opinion]int // Opinion modifiers
	Fate    map[Fate]int    // Chance modifier for fates
	Skill   map[Skill]int   // Skill modifiers
	AI      map[AIMod]int   // AI modifiers
}

func NewStats

func NewStats() *Stats

func (*Stats) Log

func (s *Stats) Log()

Log logs the stats.

type Trait

type Trait struct {
	Type          TraitType
	Opposite      *Trait
	Name          string
	Description   string
	IsExpressedBy func(*Personality) bool
	*Stats        // Contains all modifiers.
}

Trait represents a character trait that influences behavior and decisions.

func NewTrait

func NewTrait(name string, t TraitType, cond func(p *Personality) bool) *Trait

NewTrait returns a new trait.

func (*Trait) Log

func (t *Trait) Log()

Log logs the trait.

type TraitType

type TraitType int

TraitType defining how a trait can be aquired

const (
	TTypePersonality TraitType = iota
	TTypeEducation
	TTypeCongenital
	TTypeCongenitalLeveled
	TTypePhysical
	TTypeLifestyle
	TTypeLifestyleLeveled
	TTypeCommander
	TTypeInfamous
	TTypeCopingMechanism
	TTypeChildhood
	TTypeHealth
	TTypeDiseases
	TTypeDynasty
	TTypeDescendant
	TTypeDecision
	TTypeOther
)

Various trait types.

type Traiter

type Traiter struct {
	Traits []*Trait
}

Traiter is an index used for assigning traits to personalities.

func NewTraiter

func NewTraiter() *Traiter

NewTraiter returns a new Traiter index.

func (*Traiter) AddTrait

func (tt *Traiter) AddTrait(t *Trait)

AddTrait registers the given trait.

func (*Traiter) NewPersonality

func (tt *Traiter) NewPersonality() *Personality

NewPersonality returns a new, pretty boring personality.

func (*Traiter) NewPersonalityFromPreset

func (tt *Traiter) NewPersonalityFromPreset(ps map[Facet]int) *Personality

NewPersonalityFromPreset returns a new personality based on the given preset.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL