Choose an archetype with fallback to random

This commit is contained in:
Tony Bark 2025-04-28 10:46:43 -04:00
parent 5e37b43fc9
commit 1c7e301fd8
5 changed files with 82 additions and 11 deletions

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>0.3.101</Version>
<Version>0.4.101</Version>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View file

@ -1,14 +1,14 @@
namespace PersonaForge;
public class PersonalityArchetype
public class Archetypes
{
public string Name { get; set; }
public Dictionary<string, double> TraitBiases { get; set; } = new();
// TODO: Load default archetypes from a file or database
public static List<PersonalityArchetype> DefaultArchetypes() => new()
public static List<Archetypes> DefaultArchetypes() => new()
{
new PersonalityArchetype
new Archetypes
{
Name = "Grumpy",
TraitBiases = new Dictionary<string, double>
@ -20,7 +20,7 @@ public class PersonalityArchetype
{ "Active", 0.5 }
}
},
new PersonalityArchetype
new Archetypes
{
Name = "Party Animal",
TraitBiases = new Dictionary<string, double>
@ -31,6 +31,47 @@ public class PersonalityArchetype
{ "Nice", 0.5 },
{ "Neat", 0.3 }
}
},
new Archetypes
{
Name = "Lazy",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.8 },
{ "Playful", 0.6 },
{ "Outgoing", 0.4 },
{ "Neat", 0.2 },
{ "Active", 0.1 }
}
},
new Archetypes
{
Name = "Shy",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.9 },
{ "Playful", 0.7 },
{ "Outgoing", 0.3 },
{ "Neat", 0.5 },
{ "Active", 0.2 }
}
},
new Archetypes
{
Name = "Energetic",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.7 },
{ "Playful", 0.6 },
{ "Outgoing", 0.5 },
{ "Neat", 0.4 },
{ "Active", 0.3 }
}
},
new Archetypes
{
Name = "Random",
TraitBiases = new()
}
};
};
}

View file

@ -6,12 +6,24 @@ public static class PersonalityGen
const int TotalBudget = 25;
static readonly Random rng = new();
public static PersonalityTraits GenerateRandom()
public static PersonalityTraits GenerateRandom(Dictionary<string, double>? bias = null)
{
var profile = PersonalityTraits.Create();
var traits = new List<string> { "Outgoing", "Nice", "Playful", "Neat", "Active" };
var remaining = TotalBudget;
if (bias != null)
{
foreach (var kvp in bias)
{
var trait = kvp.Key;
var points = Convert.ToInt32(kvp.Value);
var safePoints = Math.Min(points, MaxPoints);
SetTraitPoints(profile, trait, safePoints);
remaining -= points;
}
}
while (remaining > 0)
{
var trait = traits[rng.Next(traits.Count)];

View file

@ -8,12 +8,30 @@ Console.WriteLine("=== Welcome to The Sims 2 Personality Generator ===");
Console.Write("Enter Sim's name: ");
string name = Console.ReadLine() ?? "Unndanmed Sim";
var qualities = PersonalityGen.GenerateRandom();
// Move the conversion logic to a separate method
Console.WriteLine("\nAvailable Archetypes:");
var archetypeList = Archetypes.DefaultArchetypes();
var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
foreach (var archetype in archetypeList)
{
Console.WriteLine($"- {archetype.Name}");
archetypeDict.Add(archetype.Name, archetype.TraitBiases);
}
Console.Write("Enter archetype: ");
string archetypeInput = Console.ReadLine() ?? "Random";
if (!archetypeDict.ContainsKey(archetypeInput))
{
Console.WriteLine("Invalid archetype. Using Random.");
archetypeInput = "Random";
}
var qualities = PersonalityGen.GenerateRandom(archetypeDict[archetypeInput]);
var profile = new PersonaProfile
{
Name = name,
Qualities = qualities,
Archetype = "Random"
Archetype = archetypeInput
};
Console.WriteLine($"{name}'s Profile{Environment.NewLine}{PersonaProfile.ToJson(profile)}");

View file

@ -18,8 +18,8 @@ With Sims 3 and later, creating personalities is as simple as selecting a trait.
| ----- | ------------------------------------------- | ------ |
| v0.1 | Core random point generator (working) | ✅ |
| v0.2 | PersonalityProfile class | ✅ |
| v0.3 | Interactive JSON export | ✅ |
| v0.4 | Archetypes with weighted biases | 🔜 |
| v0.3 | Interactive JSON export | ✅ |
| v0.4 | Archetypes with weighted biases | |
| v0.5 | Profile import/load from JSON | 🔜 |
| v1.0 | Stable "Release" version with documentation | 🔜 |