Trait Generator 2.1.2
Personality traits from a weighted catalogue with conflicts, synergies and Big Five axes for C++23
Loading...
Searching...
No Matches
dasmig::personality Class Reference

Return type for personality generation: traits and the axis values they resolve to. More...

#include <traitgen.hpp>

Classes

struct  axis
 One axis of a personality. More...
 
struct  trait
 One trait of a personality. More...
 

Public Member Functions

bool has (std::string_view key) const
 Whether the personality has a trait.
 
std::optional< double > value (std::string_view key) const
 The resolved value of an axis.
 
std::vector< std::string > tags () const
 The tags of all traits, each once, in order of appearance.
 
std::uint64_t seed () const
 Retrieve the random seed used to generate this personality.
 
const core::seed_signature & signature () const
 The seed and the data this personality was generated from.
 
std::string to_string () const
 Human-readable summary string.
 
void to_json (core::json_writer &w) const
 Write this personality as a JSON object.
 
std::string to_json () const
 This personality as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::vector< trait > traits
 Included traits first, then drawn ones.
 
std::vector< axis > axes
 Every axis, in catalogue order.
 

Friends

class trtg
 
std::ostream & operator<< (std::ostream &os, const personality &p)
 Stream the summary to an output stream.
 

Detailed Description

Return type for personality generation: traits and the axis values they resolve to.

Supports implicit conversion to std::string (the trait labels), streaming via operator<< and JSON output via to_json().

Definition at line 67 of file traitgen.hpp.

Member Function Documentation

◆ has()

bool dasmig::personality::has ( std::string_view  key) const
inline

Whether the personality has a trait.

Parameters
keyTrait key.
Returns
True when present.

Definition at line 94 of file traitgen.hpp.

◆ operator std::string()

dasmig::personality::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 185 of file traitgen.hpp.

◆ seed()

std::uint64_t dasmig::personality::seed ( ) const
inline

Retrieve the random seed used to generate this personality.

Returns
The call seed; pass it to get_personality(request, seed) with the same request and data to replay this personality.

Definition at line 127 of file traitgen.hpp.

◆ signature()

const core::seed_signature & dasmig::personality::signature ( ) const
inline

The seed and the data this personality was generated from.

Returns
The replay signature; data is trtg::data_hash() at the time of generation.

Definition at line 132 of file traitgen.hpp.

◆ tags()

std::vector< std::string > dasmig::personality::tags ( ) const
inline

The tags of all traits, each once, in order of appearance.

Returns
The tags.

Definition at line 111 of file traitgen.hpp.

◆ to_json() [1/2]

std::string dasmig::personality::to_json ( ) const
inline

This personality as a JSON document.

Returns
Compact JSON, for example {"traits":[{"key":"brave","label":"Brave","group":"courage", "tags":["combat","risk"]},...],"axes":{"openness":0.42,...}, "signature":{...}}.

Definition at line 176 of file traitgen.hpp.

◆ to_json() [2/2]

void dasmig::personality::to_json ( core::json_writer &  w) const
inline

Write this personality as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 152 of file traitgen.hpp.

◆ to_string()

std::string dasmig::personality::to_string ( ) const
inline

Human-readable summary string.

Returns
The trait labels, comma separated.

Definition at line 139 of file traitgen.hpp.

◆ value()

std::optional< double > dasmig::personality::value ( std::string_view  key) const
inline

The resolved value of an axis.

Parameters
keyAxis key.
Returns
The value, or empty for an unknown axis.

Definition at line 102 of file traitgen.hpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const personality &  p 
)
friend

Stream the summary to an output stream.

Parameters
osOutput stream.
pPersonality to stream.
Returns
The stream.

Definition at line 194 of file traitgen.hpp.

◆ trtg

friend class trtg
friend

Definition at line 202 of file traitgen.hpp.

Member Data Documentation

◆ axes

std::vector<axis> dasmig::personality::axes

Every axis, in catalogue order.

Definition at line 89 of file traitgen.hpp.

◆ traits

std::vector<trait> dasmig::personality::traits

Included traits first, then drawn ones.

Definition at line 88 of file traitgen.hpp.


The documentation for this class was generated from the following file: