From e868578f9bac9a4dfcfa557352740e312be53c77 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 10 May 2020 23:56:52 +0200 Subject: [PATCH] fixed map generation --- Game1/Sources/Crops/Crops.cs | 2 +- Game1/Sources/Crops/Farm.cs | 12 +++++++----- Game1/Sources/ML/MLModel.cs | 12 ++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index 97132da..ea27580 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -47,7 +47,7 @@ class Crops public float getSpeedFactor(float tractorSpeed) { - return 1f / getCostOnMovement(); + return (1f * tractorSpeed) / getCostOnMovement(); } public SoilProperties getSoilProperties() diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index b33d531..fa5f8ee 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -21,6 +21,7 @@ class Farm PresetCrops.init(); r = new Random(); crops = new Crops[100, 100]; + int dirtCount = 0; for (int i = 0; i < 99; i++) { for (int j = 0; j < 99; j++) @@ -40,20 +41,22 @@ class Farm x = r.Next(0, 12); crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x)); crops[i, j].init(); + + if (crops[i, j].getStatus() == 2) + { + dirtCount++; + } } } - /* - int dirtCount = 0; for (int i = 0; i < 99; i++) { for (int j = 0; j < 99; j++) { if (crops[i, j].getStatus() == 2) { - dirtCount++; if (!astar.isReachable(crops, new Vector2((int)i, (int)j), housepos)) { - crops[i, j].setStatus(1); + //crops[i, j].setStatus(1); dirtCount--; } } @@ -61,7 +64,6 @@ class Farm } if (dirtCount == 0) init(Size, housepos); - */ } public void updateFarm(Vector2 Size) diff --git a/Game1/Sources/ML/MLModel.cs b/Game1/Sources/ML/MLModel.cs index 2eec77c..1b44fed 100644 --- a/Game1/Sources/ML/MLModel.cs +++ b/Game1/Sources/ML/MLModel.cs @@ -11,12 +11,12 @@ using Microsoft.ML.Trainers.LightGbm; class MLModel { 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 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 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 reportBig = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report_BigModel"; + 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 report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report"; + 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 reportBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_BigModel"; // Loading data, creatin and saving ML model for smaller dataset (100) public static void CreateModel()