forked from s425077/PotatoPlan
Fixes and fixes
This commit is contained in:
parent
ad92969137
commit
9e07e0f6bd
8
Final_evaluation.md
Normal file
8
Final_evaluation.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Final Evaluation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Final evaluation doc.
|
||||||
|
WIP
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 4.8 MiB |
@ -207,18 +207,18 @@ class Crops
|
|||||||
|
|
||||||
public void degradeSoil()
|
public void degradeSoil()
|
||||||
{
|
{
|
||||||
|
Random r = new Random();
|
||||||
if (soilProperties.Nitrogen > 4.0f)
|
if (soilProperties.Nitrogen > 4.0f)
|
||||||
{
|
{
|
||||||
soilProperties.Nitrogen = soilProperties.Nitrogen - (soilProperties.NitrogenDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
soilProperties.Nitrogen = soilProperties.Nitrogen - ((soilProperties.NitrogenDegradeRate * (float)Math.Pow(ProductionRate, 2)) * (float)Math.Pow((r.NextDouble() + 0.5f), 2));
|
||||||
}
|
}
|
||||||
if (soilProperties.Phosphorous > 0.1f)
|
if (soilProperties.Phosphorous > 0.1f)
|
||||||
{
|
{
|
||||||
soilProperties.Phosphorous = soilProperties.Phosphorous - (soilProperties.PhosphorousDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
soilProperties.Phosphorous = soilProperties.Phosphorous - ((soilProperties.PhosphorousDegradeRate * (float)Math.Pow(ProductionRate, 2)) * (float)Math.Pow((r.NextDouble() + 0.5f), 2));
|
||||||
}
|
}
|
||||||
if (soilProperties.Potassium > 0.1f)
|
if (soilProperties.Potassium > 0.1f)
|
||||||
{
|
{
|
||||||
soilProperties.Potassium = soilProperties.Potassium - (soilProperties.PotassiumDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
soilProperties.Potassium = soilProperties.Potassium - ((soilProperties.PotassiumDegradeRate * (float)Math.Pow(ProductionRate, 2)) * (float)Math.Pow((r.NextDouble() + 0.5f), 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,13 @@ class Farm
|
|||||||
init(Size, housepos);
|
init(Size, housepos);
|
||||||
RainPosition.X = r.Next(0, 1900);
|
RainPosition.X = r.Next(0, 1900);
|
||||||
RainPosition.Y = r.Next(0, 1950);
|
RainPosition.Y = r.Next(0, 1950);
|
||||||
WindSpeed.X = GetRandomNumber(-1f, 1f) / 500;
|
float coef = GetRandomNumber(-1f, 1f);
|
||||||
WindSpeed.Y = GetRandomNumber(-1f, 1f) / 500;
|
if (coef < 0)
|
||||||
|
coef = -1.0f;
|
||||||
|
else
|
||||||
|
coef = 1.0f;
|
||||||
|
WindSpeed.X = GetRandomNumber(0.9f, 1f) / 50 * coef;
|
||||||
|
WindSpeed.Y = GetRandomNumber(0.9f, 1f) / 50 * coef;
|
||||||
//RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png");
|
//RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png");
|
||||||
RainfallMap = PerlinNoise.LoadImage("C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/Rainfall.png");
|
RainfallMap = PerlinNoise.LoadImage("C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/Rainfall.png");
|
||||||
}
|
}
|
||||||
@ -215,17 +220,17 @@ class Farm
|
|||||||
|
|
||||||
private void updateRainMapPosition(Vector2 Size)
|
private void updateRainMapPosition(Vector2 Size)
|
||||||
{
|
{
|
||||||
float x, y;
|
double x, y;
|
||||||
x = WindSpeed.X + GetRandomNumber(-1f, 1f) / 20000;
|
x = WindSpeed.X + GetRandomNumber(-1f, 1f) / 20000;
|
||||||
y = WindSpeed.Y + GetRandomNumber(-1f, 1f) / 20000;
|
y = WindSpeed.Y + GetRandomNumber(-1f, 1f) / 20000;
|
||||||
if (x <= 0.02f && x >= -0.02f)
|
if (x <= 0.02f && x >= -0.02f)
|
||||||
{
|
{
|
||||||
WindSpeed.X = x;
|
WindSpeed.X = (float)x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < 0.02f && y > -0.02f)
|
if (y < 0.02f && y > -0.02f)
|
||||||
{
|
{
|
||||||
WindSpeed.Y = y;
|
WindSpeed.Y = (float)y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WindSpeed.X > 0 && RainPosition.X < 2000)
|
if (WindSpeed.X > 0 && RainPosition.X < 2000)
|
||||||
|
@ -19,9 +19,9 @@ class SoilProperties
|
|||||||
public float Phosphorous;
|
public float Phosphorous;
|
||||||
public float Rainfall;
|
public float Rainfall;
|
||||||
public float prevRainfall;
|
public float prevRainfall;
|
||||||
public float NitrogenDegradeRate = 1.0f - (1.0f/55 * 40);
|
public float NitrogenDegradeRate = 0.8f;
|
||||||
public float PotassiumDegradeRate = 1.0f - (1.0f/28 * 23);
|
public float PotassiumDegradeRate = 0.3f;
|
||||||
public float PhosphorousDegradeRate = 1.0f - (1.0f/60 * 37);
|
public float PhosphorousDegradeRate = 0.6f;
|
||||||
public int Capacity = 80;
|
public int Capacity = 80;
|
||||||
public int Area;
|
public int Area;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ using Microsoft.ML.Trainers.LightGbm;
|
|||||||
class MLModel
|
class MLModel
|
||||||
{
|
{
|
||||||
private static MLContext mlContext = new MLContext(seed: 1);
|
private static MLContext mlContext = new MLContext(seed: 1);
|
||||||
/*
|
|
||||||
private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Fertilizer_Prediction.csv";
|
private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Fertilizer_Prediction.csv";
|
||||||
private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel";
|
private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel";
|
||||||
private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report";
|
private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report";
|
||||||
@ -19,7 +19,7 @@ class MLModel
|
|||||||
private static string pathBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/BigFertPredict.csv";
|
private static string pathBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/BigFertPredict.csv";
|
||||||
private static string modelpathBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodelBig";
|
private static string modelpathBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodelBig";
|
||||||
private static string reportBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_BigModel";
|
private static string reportBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_BigModel";
|
||||||
*/
|
/*
|
||||||
private static string pathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/BigFertPredict.csv";
|
private static string pathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/BigFertPredict.csv";
|
||||||
private static string modelpathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodelBig";
|
private static string modelpathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodelBig";
|
||||||
private static string reportBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_BigModel";
|
private static string reportBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_BigModel";
|
||||||
@ -27,7 +27,7 @@ class MLModel
|
|||||||
private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Fertilizer_Prediction.csv";
|
private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Fertilizer_Prediction.csv";
|
||||||
private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel";
|
private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel";
|
||||||
private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report";
|
private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report";
|
||||||
|
*/
|
||||||
// Loading data, creatin and saving ML model for smaller dataset (100)
|
// Loading data, creatin and saving ML model for smaller dataset (100)
|
||||||
public static void CreateModel()
|
public static void CreateModel()
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace Game1.Sources.ML_Joel
|
|||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
private static MLContext mlContext = new MLContext(seed: 1);
|
private static MLContext mlContext = new MLContext(seed: 1);
|
||||||
/*
|
|
||||||
private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Rainfall.csv";
|
private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Rainfall.csv";
|
||||||
private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel_Joel";
|
private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel_Joel";
|
||||||
private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_Joel";
|
private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_Joel";
|
||||||
@ -21,8 +21,8 @@ namespace Game1.Sources.ML_Joel
|
|||||||
private static string path_area = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Rainfall_area.csv";
|
private static string path_area = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Rainfall_area.csv";
|
||||||
private static string modelpath_area = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel_Joel_area";
|
private static string modelpath_area = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel_Joel_area";
|
||||||
private static string report_area = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_Joel_area";
|
private static string report_area = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_Joel_area";
|
||||||
*/
|
|
||||||
|
|
||||||
|
/*
|
||||||
private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Rainfall.csv";
|
private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Rainfall.csv";
|
||||||
private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel_Joel";
|
private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel_Joel";
|
||||||
private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_Joel";
|
private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_Joel";
|
||||||
@ -30,7 +30,7 @@ namespace Game1.Sources.ML_Joel
|
|||||||
private static string path_area = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Rainfall_area.csv";
|
private static string path_area = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Rainfall_area.csv";
|
||||||
private static string modelpath_area = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel_Joel_area";
|
private static string modelpath_area = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel_Joel_area";
|
||||||
private static string report_area = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_Joel_area";
|
private static string report_area = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_Joel_area";
|
||||||
|
*/
|
||||||
// Loading data, creatin and saving ML model for smaller dataset (100)
|
// Loading data, creatin and saving ML model for smaller dataset (100)
|
||||||
public static void CreateModel()
|
public static void CreateModel()
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,7 @@ class Inventory
|
|||||||
private int[] totalFertilizerUsed = new int[8];
|
private int[] totalFertilizerUsed = new int[8];
|
||||||
private Cargo cargo = new Cargo();
|
private Cargo cargo = new Cargo();
|
||||||
private Cargo itemStorage = new Cargo();
|
private Cargo itemStorage = new Cargo();
|
||||||
|
private int Refills = 0;
|
||||||
|
|
||||||
// Item list by index:
|
// Item list by index:
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@ -128,17 +129,63 @@ class Inventory
|
|||||||
|
|
||||||
for (int i = 0; i <= 10; i++)
|
for (int i = 0; i <= 10; i++)
|
||||||
while (useItem(i, 1, true)) ;
|
while (useItem(i, 1, true)) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillWithFertilizer()
|
public void fillWithFertilizer()
|
||||||
{
|
{
|
||||||
int i = 0;
|
Refills++;
|
||||||
while (getWeight() < getMaxWeight())
|
int fert_amount = 7;
|
||||||
|
float weightPerFertilizer = maxWeight / fert_amount;
|
||||||
|
float min = weightPerFertilizer / 10;
|
||||||
|
float max = (2 * weightPerFertilizer) - min;
|
||||||
|
float expectedUse = Refills * weightPerFertilizer;
|
||||||
|
|
||||||
|
double[] useFactor = new double[fert_amount];
|
||||||
|
for (int i = 0; i < fert_amount; i++)
|
||||||
{
|
{
|
||||||
if (i > 6)
|
if (Refills <= 1)
|
||||||
i = 0;
|
useFactor[i] = weightPerFertilizer;
|
||||||
addItem(i, 0);
|
else
|
||||||
i++;
|
if (totalFertilizerUsed[i] / expectedUse + 0.85f > 1.0f)
|
||||||
|
useFactor[i] = Math.Round(Math.Pow((totalFertilizerUsed[i] / expectedUse) + 0.50f, 0.6f + Math.Min(Refills / 6.0f, 1.0f)) * weightPerFertilizer);
|
||||||
|
else
|
||||||
|
useFactor[i] = Math.Round(Math.Pow((totalFertilizerUsed[i] / expectedUse) + 0.50f, 1.0f + Math.Min(Refills / 6.0f, 1.8f)) * weightPerFertilizer);
|
||||||
|
if (useFactor[i] < min)
|
||||||
|
useFactor[i] = min;
|
||||||
|
else if (useFactor[i] > max)
|
||||||
|
useFactor[i] = max;
|
||||||
|
}
|
||||||
|
int j = 0;
|
||||||
|
bool change = false;
|
||||||
|
while (getWeight() < getMaxWeight() - fert_amount)
|
||||||
|
{
|
||||||
|
if (useFactor[j] > 0)
|
||||||
|
{
|
||||||
|
addItem(j, 0);
|
||||||
|
useFactor[j]--;
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
if (j >= fert_amount)
|
||||||
|
{
|
||||||
|
if (!change)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j = 0;
|
||||||
|
change = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int m = 0;
|
||||||
|
while (getWeight() < getMaxWeight()- fert_amount)
|
||||||
|
{
|
||||||
|
if (m > 6)
|
||||||
|
m = 0;
|
||||||
|
addItem(m, 0);
|
||||||
|
m++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user