"From [Under the Hood of The Sims](https://users.cs.northwestern.edu/~forbus/c95-gd/lectures/The_Sims_Under_the_Hood_files/v3_document.htm)\n",
"\n",
"The Motive Engine is based on opposing weights. An object signals it's presence if the Sims' need is low. The need is the motive and that drives a Sims' decision. All games in the franchise are based on this dynamic at it's core. For example, if hunger is low then the fridge's presence is high and vice versa. The sum of all the Sims' needs is it's mood. A Sim will only choose the fridge if it increases it's overall mood. The sum of all the Sims' needs is it's mood. A Sim will only choose the fridge if it increases it's overall mood. The ML portion comes in deciding which has the priority."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"using System;\n",
"using System.Linq;"
],
"outputs": []
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"public static int LimitToRange(this int val, int min, int max)\n",
"{\n",
" if (val < min) { return min; }\n",
" if (val > max) { return max; }\n",
" return val;\n",
"}"
],
"outputs": []
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"class Motives\n",
"{\n",
" public Motives(int hunger, int bladder, int fun, int energy, \n",
" int environment, int social)\n",
" {\n",
" Hunger = hunger;\n",
" Bladder = bladder;\n",
" Fun = fun;\n",
" Energy = energy;\n",
" Environment = environment;\n",
" Social = social;\n",
" }\n",
"\n",
" public int Hunger { get; set; }\n",
" public int Bladder { get; set; }\n",
" public int Fun { get; set; }\n",
" public int Energy { get; set; }\n",
" public int Environment { get; set; }\n",
" public int Social { get; set; }\n",
"\n",
" int MaxMood = 60;\n",
"\n",
" /// <summary>\n",
" /// The mood is the sum of all the motives.\n",
" /// It deteremines the best course of action.\n",
" /// </summary>\n",
" public int Mood\n",
" {\n",
" get\n",
" {\n",
" var curMood = new[] { Hunger, Bladder, Fun,\n",
" Social, Environment, Energy };\n",
"\n",
" return curMood.Sum();\n",
" }\n",
" }\n",
"\n",
" // In the game, this would increament gradually\n",
" // until it reaches it's max motive.\n",
" int CalcuateMotiveChange(int motive, int input)\n",