Renamed SetTraitHigher to RebalanceTraits
- Rebalance method now accounts for high and low personality points are
This commit is contained in:
parent
f6ef83fd91
commit
85ce1f4023
3 changed files with 32 additions and 27 deletions
|
@ -1,14 +1,11 @@
|
||||||
using SimsPersonalityGenerator;
|
using SimsPersonalityGenerator;
|
||||||
|
|
||||||
var sim = new Sim();
|
var sim = new Sim();
|
||||||
|
|
||||||
Console.WriteLine("Generated Personality:");
|
Console.WriteLine("Generated Personality:");
|
||||||
Console.WriteLine(sim);
|
Console.WriteLine(sim);
|
||||||
|
|
||||||
// Example of setting one trait higher and compensating for the differences
|
// Example of setting one trait higher and compensating for the differences
|
||||||
Console.WriteLine("\nSetting Niceness higher...");
|
Console.WriteLine("\nSetting niceness higher...");
|
||||||
sim.SetTraitHigher(Traits.Nice, true);
|
sim.RebalanceTraits(Traits.Nice, true);
|
||||||
Console.WriteLine(sim);
|
|
||||||
|
|
||||||
Console.WriteLine("\nSetting Neatness lower...");
|
|
||||||
sim.SetTraitHigher(Traits.Neat, false);
|
|
||||||
Console.WriteLine(sim);
|
Console.WriteLine(sim);
|
|
@ -1,12 +1,12 @@
|
||||||
# Sims Personality Generator
|
# Sims Personality Generator
|
||||||
|
|
||||||
As the name suggests, this will generate a personality for The Sims 1 and 2. If you set one trait higher than other, it will automatically adjust itself to compensate for the difference.
|
As the name suggests, this will generate a personality for The Sims 1 and 2. If you choose to have a bias towards one trait being higher over the others, it will automatically compensate for the difference. It is recommended to only set a bias towards one trait at a time.
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
I wanted to play The Sims 2 with my characters. Problem was I've been spoiled by traits. How do I create an ideal personality within these limitations? What if I have a random generator that gives me some options but also is smart enough to let me set some bias towards Playfulness or Nice?
|
I wanted to play The Sims 2 with my characters. Problem was I've been spoiled by traits. How do I create an ideal personality within these limitations? What if I have a random generator that gives me some options but also is smart enough to let me set some bias towards Playfulness or Nice?
|
||||||
|
|
||||||
The code itself was initially generated using the Qwen Coder model because I wouldn't know to begin. While it is easy to generate random numbers, I also had to have it to account for one being higher than the other. How? That was the point in asking the AI for a template, with that taken into consideration.
|
The code itself was initially generated using the [Qwen Coder](https://qwenlm.github.io/blog/qwen2.5-coder-family/) model because I wouldn't know to begin. While it is easy to generate random numbers, I also had to have it to account for one being higher than the other. How? That was the point in asking the AI for a template, with that taken into consideration.
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
46
Sim.cs
46
Sim.cs
|
@ -11,6 +11,9 @@ public class Sim
|
||||||
public int Active { get; private set; }
|
public int Active { get; private set; }
|
||||||
public int Playful { get; private set; }
|
public int Playful { get; private set; }
|
||||||
|
|
||||||
|
const int MIN_HIGHEST_POINT = 8;
|
||||||
|
const int MAX_LOWEST_POINT = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the Sim class with a random personality.
|
/// Initializes a new instance of the Sim class with a random personality.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -24,40 +27,39 @@ public class Sim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trait">The name of the trait to adjust.</param>
|
/// <param name="trait">The name of the trait to adjust.</param>
|
||||||
/// <param name="isHigh">True if the trait should be set higher, false if it should be set lower.</param>
|
/// <param name="isHigh">True if the trait should be set higher, false if it should be set lower.</param>
|
||||||
// TODO: Fix trait mix up
|
public void RebalanceTraits(Traits trait, bool isHigh = false)
|
||||||
public void SetTraitHigher(Traits trait, bool isHigh)
|
|
||||||
{
|
{
|
||||||
switch (trait)
|
switch (trait)
|
||||||
{
|
{
|
||||||
case Traits.Nice:
|
case Traits.Nice:
|
||||||
if (isHigh)
|
if (isHigh && Nice >= MAX_LOWEST_POINT)
|
||||||
Nice = Math.Min(8, Neat + 5);
|
Nice = Math.Min(MIN_HIGHEST_POINT, Neat + 5);
|
||||||
else
|
else
|
||||||
Neat = Math.Min(8, Nice + 5);
|
Neat = Math.Min(MIN_HIGHEST_POINT, Nice + 5);
|
||||||
break;
|
break;
|
||||||
case Traits.Neat:
|
case Traits.Neat:
|
||||||
if (isHigh)
|
if (isHigh && Neat >= MAX_LOWEST_POINT)
|
||||||
Neat = Math.Min(8, Active + 5);
|
Neat = Math.Min(MIN_HIGHEST_POINT, Active + 5);
|
||||||
else
|
else
|
||||||
Active = Math.Min(8, Neat + 5);
|
Active = Math.Min(MIN_HIGHEST_POINT, Neat + 5);
|
||||||
break;
|
break;
|
||||||
case Traits.Outgoing:
|
case Traits.Outgoing:
|
||||||
if (isHigh)
|
if (isHigh && Outgoing >= MAX_LOWEST_POINT)
|
||||||
Outgoing = Math.Min(8, Playful + 5);
|
Outgoing = Math.Min(MIN_HIGHEST_POINT, Playful + 5);
|
||||||
else
|
else
|
||||||
Playful = Math.Min(8, Outgoing + 5);
|
Playful = Math.Min(MIN_HIGHEST_POINT, Outgoing + 5);
|
||||||
break;
|
break;
|
||||||
case Traits.Active:
|
case Traits.Active:
|
||||||
if (isHigh)
|
if (isHigh && Active >= MAX_LOWEST_POINT)
|
||||||
Active = Math.Min(8, Nice + 5);
|
Active = Math.Min(MIN_HIGHEST_POINT, Nice + 5);
|
||||||
else
|
else
|
||||||
Nice = Math.Min(8, Active + 5);
|
Nice = Math.Min(MIN_HIGHEST_POINT, Active + 5);
|
||||||
break;
|
break;
|
||||||
case Traits.Playful:
|
case Traits.Playful:
|
||||||
if (isHigh)
|
if (isHigh && Playful >= MAX_LOWEST_POINT)
|
||||||
Playful = Math.Min(8, Outgoing + 5);
|
Playful = Math.Min(MIN_HIGHEST_POINT, Outgoing + 5);
|
||||||
else
|
else
|
||||||
Outgoing = Math.Min(8, Playful + 5);
|
Outgoing = Math.Min(MIN_HIGHEST_POINT, Playful + 5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException("Invalid trait name.");
|
throw new ArgumentException("Invalid trait name.");
|
||||||
|
@ -67,7 +69,7 @@ public class Sim
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a random personality with balanced traits.
|
/// Generates a random personality with balanced traits.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void GenerateRandomPersonality()
|
public void GenerateRandomPersonality()
|
||||||
{
|
{
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
Nice = rand.Next(11);
|
Nice = rand.Next(11);
|
||||||
|
@ -107,6 +109,12 @@ public class Sim
|
||||||
Playful = Playful;
|
Playful = Playful;
|
||||||
Active = Active;
|
Active = Active;
|
||||||
};
|
};
|
||||||
return JsonSerializer.Serialize<Sim>(sim);
|
|
||||||
|
var options = new JsonSerializerOptions()
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonSerializer.Serialize<Sim>(sim, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue