I'm coding a game where after every year depending on results the attributes of characters change. The game is a movie business simulator and here is a example of the ugly code I have in place now:
if (movie.Reviews.Avg > 8.5f)
{
movie.Producer.Reputation += 6f / movie.Producer.Reputation;
return;
}
else if (movie.Reviews.Avg > 7.5f)
{
movie.Producer.Reputation += 5f / movie.Producer.Reputation;
return;
}
else if (movie.Reviews.Avg > 6.5f)
{
movie.Producer.Reputation += 4f / movie.Producer.Reputation;
return;
}
else if (movie.Reviews.Avg > 5)
{
movie.Producer.Reputation += 1f / movie.Producer.Reputation;
return;
}
else if (movie.Reviews.Avg > 4.5)
{
return;
}
else if (movie.Reviews.Avg > 4)
{
movie.Producer.Reputation -= movie.Producer.Reputation / 6f;
return;
}
else if (movie.Reviews.Avg > 3)
{
movie.Producer.Reputation -= movie.Producer.Reputation / 5f;
return;
}
else if (movie.Reviews.Avg > 2)
{
movie.Producer.Reputation -= movie.Producer.Reputation / 4f;
return;
}
else
{
movie.Producer.Reputation -= movie.Producer.Reputation / 3f;
return;
}
Few problems I have with this code:
Reputations balloon. Good AI producers make good choices so their movies get good reviews and their reputation goes even higher.
Because reputations keep growing the absolute changes in attributes get smaller and moving up in ranks gets way too slow and hard.
What I am looking from the function:
- Range is 0-10.
- At the top of the range growth is slow even with great reviews, but if your movie gets bad reviews the decline is sharp. And the opposite for the bottom of the range.