mirror of
https://github.com/simtactics/servo.git
synced 2025-07-14 18:21:53 -04:00
Temporarily removed Visual Studio solution
- WIP decision engine - Redesigned choice dataset - Moved data, images and models folders into notebooks directory for easier eaccess
This commit is contained in:
parent
31024f9fc5
commit
929b96b07b
16 changed files with 114 additions and 761 deletions
3
notebooks/data/choice.csv
Normal file
3
notebooks/data/choice.csv
Normal file
|
@ -0,0 +1,3 @@
|
|||
Action,Need,Min,Max
|
||||
Refrigerator,Hunger,10,30
|
||||
Toy,Fun,60,70
|
|
79
notebooks/decision.ipynb
Normal file
79
notebooks/decision.ipynb
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#r \"nuget:Microsoft.ML\"\n",
|
||||
"#r \"nuget:Microsoft.ML.AutoML\""
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"using Microsoft.ML;\n",
|
||||
"using Microsoft.ML.Data;\n",
|
||||
"using Microsoft.ML.AutoML;\n",
|
||||
"using System.IO;"
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"class NeedsInput {\n",
|
||||
" [LoadColumn(0)] public string Action { get; set; }\n",
|
||||
" [LoadColumn(1)] public string Need { get; set; }\n",
|
||||
" [LoadColumn(2,3)] public float[] Threshold { get; set; }\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"class NeedsOutput {\n",
|
||||
" public int Score { get; set; }\n",
|
||||
"}"
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"var dataPath = Path.Combine(Environment.CurrentDirectory, \"data\", \"choice.csv\");"
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"var ctx = new MLContext();\n",
|
||||
"var trainingData = ctx.Data.LoadFromTextFile<NeedsInput>(dataPath, hasHeader: true);\n",
|
||||
"var recSettings = new RecommendationExperimentSettings();"
|
||||
],
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".NET (C#)",
|
||||
"language": "C#",
|
||||
"name": ".net-csharp"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".cs",
|
||||
"mimetype": "text/x-csharp",
|
||||
"name": "C#",
|
||||
"pygments_lexer": "csharp",
|
||||
"version": "8.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
BIN
notebooks/images/v3_slide0094_image039.gif
Normal file
BIN
notebooks/images/v3_slide0094_image039.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
0
notebooks/models/.gitkeep
Normal file
0
notebooks/models/.gitkeep
Normal file
|
@ -6,7 +6,7 @@
|
|||
"source": [
|
||||
"# Motive Engine\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"The Motive Engine is based on opposing weights. An object signals it's presence if the Sim's 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. A Sim's mood is the sum of the current state of their motives. They will only choose the fridge if it increases it's overall mood. The ML portion comes in deciding which has the priority.\n",
|
||||
"\n",
|
||||
|
@ -18,7 +18,15 @@
|
|||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"using System;\n",
|
||||
"#r \"nuget:Microsoft.ML\""
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"using System.Linq;"
|
||||
],
|
||||
"outputs": []
|
||||
|
@ -76,10 +84,8 @@
|
|||
" public int Environment { get; set; }\n",
|
||||
" public int Social { get; set; }\n",
|
||||
"\n",
|
||||
" /// <summary>\n",
|
||||
" /// The mood is the sum of all the motives.\n",
|
||||
" /// It deteremines the best course of action.\n",
|
||||
" /// </summary>\n",
|
||||
" // The mood is the sum of all the motives.\n",
|
||||
" // It deteremines the best course of action.\n",
|
||||
" public int Mood\n",
|
||||
" {\n",
|
||||
" get\n",
|
||||
|
@ -174,6 +180,7 @@
|
|||
"source": [
|
||||
"// Run this first\n",
|
||||
"var rng = new Random();\n",
|
||||
"\n",
|
||||
"var motives = new Motives(hunger: rng.Next(MAX_MOTIVE), \n",
|
||||
"bladder: rng.Next(MAX_MOTIVE), fun: rng.Next(MAX_MOTIVE), \n",
|
||||
"energy: rng.Next(MAX_MOTIVE), environment: rng.Next(MAX_MOTIVE), \n",
|
||||
|
@ -190,6 +197,8 @@
|
|||
"source": [
|
||||
"// Run this next\n",
|
||||
"var newRng = new Random();\n",
|
||||
"\n",
|
||||
"// Minimum random number is whatever the current motive is\n",
|
||||
"motives.ChangeHunger(newRng.Next(motives.Hunger, MAX_MOTIVE));\n",
|
||||
"motives.ChangeFun(newRng.Next(motives.Fun, MAX_MOTIVE));\n",
|
||||
"motives.ChangeSocial(newRng.Next(motives.Social, MAX_MOTIVE));\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue