1
0
forked from s425077/PotatoPlan

ml implement

This commit is contained in:
BOTLester 2020-05-24 22:21:49 +02:00
parent 6bb5073048
commit e406823e47
3 changed files with 30 additions and 8 deletions

View File

@ -22,8 +22,8 @@ class Crops
SoilProperties soilProperties = new SoilProperties(); SoilProperties soilProperties = new SoilProperties();
private float ProductionRate; private float ProductionRate;
private float tempRain; private float tempRain;
public DayNightCycle Time { get; set; } private DayNightCycle Time = new DayNightCycle();
public void updateCrop(Vector2 newSize, float Rain, DayNightCycle nTime) public void updateCrop(Vector2 newSize, float Rain, DayNightCycle nTime)
@ -328,6 +328,28 @@ class Crops
public float getProductionRate(CropTypes Sample) public float getProductionRate(CropTypes Sample)
{ {
float predProd = 1.0f;
if (Status > 1)
{
bool correctSeason = false;
foreach (string i in Sample.Season)
{
if (i == Time.getTimeOfYear() || i == "Whole Year")
{
correctSeason = true;
break;
}
}
if (correctSeason)
{
predProd = Game1.Sources.ML_Joel.Engine.PredictProductionwithRainfall(soilProperties, Time);
predProd = (predProd / soilProperties.Area) / 2;
}
else
predProd = 0.20f;
}
ProductionRate = 1; ProductionRate = 1;
float min = 1.0f; float min = 1.0f;
if (DataSet != null) if (DataSet != null)
@ -366,7 +388,7 @@ class Crops
ProductionRate = ProductionRate / 1.5f; ProductionRate = ProductionRate / 1.5f;
} }
ProductionRate = (float)Math.Pow(ProductionRate, 2.5f); ProductionRate = (float)Math.Pow(ProductionRate, 2.5f);
return ProductionRate; return ProductionRate * predProd;
} }
public float getProductionRate() public float getProductionRate()

View File

@ -35,13 +35,13 @@ namespace Game1.Sources.ML_Joel
PredictionEngineArea = Model.CreateEngineArea(); PredictionEngineArea = Model.CreateEngineArea();
} }
public static float PredictProductionwithRainfall(Crops crop, CropTypes cropTypes) public static float PredictProductionwithRainfall(SoilProperties soilProperties, DayNightCycle Time)
{ {
InputArea modelInput = new InputArea InputArea modelInput = new InputArea
{ {
//Season = crop. Season = Time.getTimeOfYear(),
//Area = crop.getSoilProperties().Area, Area = soilProperties.Area,
Rainfall = crop.getSoilProperties().Humidity, Rainfall = soilProperties.Humidity,
}; };
return PredictionEngineArea.Predict(modelInput).Score; return PredictionEngineArea.Predict(modelInput).Score;

View File

@ -16,7 +16,7 @@ class SmartTractor
//What to do next //What to do next
public Path returnChoice() public Path returnChoice()
{ {
//System.Threading.St //System.Threading.ThreadStart tractorThread = new System.Threading.ThreadStart(farm.UpdatePreferedCrops);
ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation); ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
farm.UpdatePreferedCrops(Size); farm.UpdatePreferedCrops(Size);
farm = ai.changeCropStatus(); farm = ai.changeCropStatus();