From 090a612660c1197f1e696049b62a153043cbfe6c Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 25 May 2020 10:59:17 +0200 Subject: [PATCH] asd --- Game1/Sources/Crops/Crops.cs | 21 +++++++++++---------- Game1/Sources/Crops/Farm.cs | 14 ++++++++++---- Game1/Sources/ML_Joel/Engine.cs | 1 + Game1/Sources/Objects/DayNightCycle.cs | 13 ++++++++++--- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index e47c5b6..40973fc 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -22,17 +22,17 @@ class Crops SoilProperties soilProperties = new SoilProperties(); private float ProductionRate; private float tempRain; + private float prevpred; private DayNightCycle Time = new DayNightCycle(); - public void updateCrop(Vector2 newSize, float Rain, DayNightCycle nTime) + public void updateCrop(Vector2 newSize, DayNightCycle nTime) { Time = nTime; - tempRain = Rain; if (UpdateCrop == 60) { - degradeSoil(Rain); + degradeSoil(); UpdateCrop = 0; } @@ -204,7 +204,7 @@ class Crops } } - public void degradeSoil(float Rain) + public void degradeSoil() { if (soilProperties.Nitrogen > 4.0f) @@ -219,13 +219,14 @@ class Crops { soilProperties.Potassium = soilProperties.Potassium - (soilProperties.PotassiumDegradeRate * (float)Math.Pow(ProductionRate, 2)); } + } - + public void updateRainfall(float Rain) + { if (Rain >= 0.45f) { - soilProperties.Rainfall = soilProperties.Rainfall + Rain * 600; + soilProperties.Rainfall = soilProperties.Rainfall + Rain * 4; } - } public void setPrevRainfall() @@ -333,7 +334,7 @@ class Crops public float getProductionRate(CropTypes Sample) { float predProd = 1.0f; - if (Status > 1) + if (Status > 1 && Time.nDay()) { bool correctSeason = false; foreach (string i in Sample.Season) @@ -353,7 +354,7 @@ class Crops else predProd = 0.20f; } - + prevpred = predProd; ProductionRate = 1; float min = 1.0f; if (DataSet != null) @@ -392,7 +393,7 @@ class Crops ProductionRate = ProductionRate / 1.5f; } ProductionRate = (float)Math.Pow(ProductionRate, 2.5f); - return ProductionRate * predProd; + return ProductionRate * prevpred; } public float getProductionRate() diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index 93ff002..a9b8ac1 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -50,7 +50,7 @@ class Farm crops[i, j] = new Crops(); crops[i, j].setStatus(x); crops[i, j].setOriginalStatus(); - x = r.Next(0, 12); + x = r.Next(1, 12); crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x)); crops[i, j].init(); @@ -131,12 +131,14 @@ class Farm temp.X = i + ((1999 - (int)Math.Round(RainPosition.X))); if (temp.Y >= 1999 - Size.Y - 1) temp.Y = i + ((1999 - (int)Math.Round(RainPosition.Y))); - crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness(), Time); + crops[i, j].updateCrop(Size, Time); + crops[i, j].updateRainfall(RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness()); } } Update = 0; } + updateRainMapPosition(Size); if (productionUpdate == 60) { nextUpdate = updateProgress + updatePerc; @@ -144,7 +146,12 @@ class Farm { for (int j = 0; j < Size.Y; j++) { - crops[i, j].updateProductionRate(); + if (crops[i, j].getStatus() > 1) + { + int x = getHighestProductionRate(i, j); + crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x)); + crops[i, j].updateProductionRate(); + } } } updateProgress = updateProgress + updatePerc; @@ -152,7 +159,6 @@ class Farm { updateProgress = 0; } - updateRainMapPosition(Size); productionUpdate = 0; nextUpdate = 0; } diff --git a/Game1/Sources/ML_Joel/Engine.cs b/Game1/Sources/ML_Joel/Engine.cs index aac86d7..fbc1e05 100644 --- a/Game1/Sources/ML_Joel/Engine.cs +++ b/Game1/Sources/ML_Joel/Engine.cs @@ -46,6 +46,7 @@ namespace Game1.Sources.ML_Joel return PredictionEngineArea.Predict(modelInput).Score; } + } } diff --git a/Game1/Sources/Objects/DayNightCycle.cs b/Game1/Sources/Objects/DayNightCycle.cs index d86e74a..4c797f1 100644 --- a/Game1/Sources/Objects/DayNightCycle.cs +++ b/Game1/Sources/Objects/DayNightCycle.cs @@ -7,25 +7,31 @@ using Microsoft.Xna.Framework; class DayNightCycle { - private bool Time = false; + private bool Time = true; + private bool Day = true; private int nightTime = 0; private int dayTime = 0; private int lengthOfDay = 20000; private int lengthOfNight = 20000; private int Days = 1; private int DaysOfYear = 0; + private int speed = 1; + private bool nextDay = true; + public void updateTime(int Speed) { + speed = Speed; Time = false; for (int i = 0; i < Speed; i++) { - if (Time) + if (Day) { dayTime++; if (dayTime == lengthOfDay) { Time = false; + Day = false; dayTime = 0; } } @@ -35,6 +41,7 @@ class DayNightCycle if (nightTime == lengthOfNight) { Time = true; + Day = true; nightTime = 0; Days++; DaysOfYear++; @@ -136,7 +143,7 @@ class DayNightCycle public int GetTimeOfDayInt() { - if (Time) + if (Day) { return (int)(100 * ((float)(dayTime + nightTime) / (lengthOfDay + lengthOfNight))) + 1; }