forked from s425077/PotatoPlan
52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
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);
|
|
private static PredictionEngine<Input, Output> PredictionEngine;
|
|
private static PredictionEngine<InputArea, OutputArea> PredictionEngineArea;
|
|
|
|
|
|
public static void CreateModel()
|
|
{
|
|
Model.CreateModel();
|
|
}
|
|
|
|
public static void CreateModelArea()
|
|
{
|
|
Model.CreateModelArea();
|
|
}
|
|
|
|
public static void init()
|
|
{
|
|
PredictionEngine = Model.CreateEngine();
|
|
}
|
|
|
|
public static void initArea()
|
|
{
|
|
PredictionEngineArea = Model.CreateEngineArea();
|
|
}
|
|
|
|
public static float PredictProductionwithRainfall(SoilProperties soilProperties, DayNightCycle Time)
|
|
{
|
|
InputArea modelInput = new InputArea
|
|
{
|
|
Season = Time.getTimeOfYear(),
|
|
Area = soilProperties.Area,
|
|
Rainfall = soilProperties.prevRainfall,
|
|
};
|
|
|
|
return PredictionEngineArea.Predict(modelInput).Score;
|
|
}
|
|
}
|
|
}
|
|
|