PotatoPlan/Game1/Sources/ML_Joel/Engine.cs

56 lines
1.4 KiB
C#
Raw Permalink Normal View History

2020-05-24 01:57:27 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ML;
namespace Game1.Sources.ML_Joel
{
static class Engine
{
private static MLContext mlContext = new MLContext(seed: 1);
2020-05-24 21:00:54 +02:00
private static PredictionEngine<Input, Output> PredictionEngine;
private static PredictionEngine<InputArea, OutputArea> PredictionEngineArea;
2020-06-14 18:01:51 +02:00
private static OutputArea modelOutput;
2020-05-24 21:00:54 +02:00
2020-05-24 01:57:27 +02:00
public static void CreateModel()
{
Model.CreateModel();
}
2020-05-24 21:00:54 +02:00
public static void CreateModelArea()
{
Model.CreateModelArea();
}
2020-05-24 01:57:27 +02:00
public static void init()
{
2020-05-24 21:00:54 +02:00
PredictionEngine = Model.CreateEngine();
}
public static void initArea()
{
PredictionEngineArea = Model.CreateEngineArea();
2020-05-24 01:57:27 +02:00
}
2020-05-24 22:21:49 +02:00
public static float PredictProductionwithRainfall(SoilProperties soilProperties, DayNightCycle Time)
2020-05-24 01:57:27 +02:00
{
2020-05-24 21:00:54 +02:00
InputArea modelInput = new InputArea
2020-05-24 01:57:27 +02:00
{
2020-05-24 22:21:49 +02:00
Season = Time.getTimeOfYear(),
Area = soilProperties.Area,
2020-05-25 00:03:32 +02:00
Rainfall = soilProperties.prevRainfall,
2020-05-24 01:57:27 +02:00
};
2020-06-14 18:01:51 +02:00
//OutputArea modelOutput = new OutputArea();
2020-05-25 11:07:58 +02:00
PredictionEngineArea.Predict(modelInput, ref modelOutput);
return modelOutput.Score;
2020-05-24 01:57:27 +02:00
}
2020-05-25 10:59:17 +02:00
2020-05-24 01:57:27 +02:00
}
}