updating dev branch
This commit is contained in:
commit
8c976c4beb
1600
Game1/Content/ML/BigFertPredict.csv
Normal file
1600
Game1/Content/ML/BigFertPredict.csv
Normal file
File diff suppressed because it is too large
Load Diff
100
Game1/Content/ML/Fertilizer_Prediction.csv
Normal file
100
Game1/Content/ML/Fertilizer_Prediction.csv
Normal file
@ -0,0 +1,100 @@
|
||||
Temparature,Humidity ,Moisture,Soil Type,Crop Type,Nitrogen,Potassium,Phosphorous,Fertilizer Name
|
||||
26,52,38,Sandy,Maize,37,0,0,Urea
|
||||
29,52,45,Loamy,Sugarcane,12,0,36,DAP
|
||||
34,65,62,Black,Cotton,7,9,30,14-35-14
|
||||
32,62,34,Red,Tobacco,22,0,20,28-28
|
||||
28,54,46,Clayey,Paddy,35,0,0,Urea
|
||||
26,52,35,Sandy,Barley,12,10,13,17-17-17
|
||||
25,50,64,Red,Cotton,9,0,10,20-20
|
||||
33,64,50,Loamy,Wheat,41,0,0,Urea
|
||||
30,60,42,Sandy,Millets,21,0,18,28-28
|
||||
29,58,33,Black,Oil seeds,9,7,30,14-35-14
|
||||
27,54,28,Clayey,Pulses,13,0,40,DAP
|
||||
31,62,48,Sandy,Maize,14,15,12,17-17-17
|
||||
25,50,65,Loamy,Cotton,36,0,0,Urea
|
||||
32,62,41,Clayey,Paddy,24,0,22,28-28
|
||||
26,52,31,Red,Ground Nuts,14,0,41,DAP
|
||||
31,62,49,Black,Sugarcane,10,13,14,17-17-17
|
||||
33,64,34,Clayey,Pulses,38,0,0,Urea
|
||||
25,50,39,Sandy,Barley,21,0,19,28-28
|
||||
28,54,65,Black,Cotton,39,0,0,Urea
|
||||
29,58,52,Loamy,Wheat,13,0,36,DAP
|
||||
30,60,44,Sandy,Millets,10,0,9,20-20
|
||||
34,65,53,Loamy,Sugarcane,12,14,12,17-17-17
|
||||
35,68,33,Red,Tobacco,11,0,37,DAP
|
||||
28,54,37,Black,Millets,36,0,0,Urea
|
||||
33,64,39,Clayey,Paddy,13,0,10,20-20
|
||||
26,52,44,Sandy,Maize,23,0,20,28-28
|
||||
30,60,63,Red,Cotton,9,9,29,14-35-14
|
||||
32,62,30,Loamy,Sugarcane,38,0,0,Urea
|
||||
37,70,32,Black,Oil seeds,12,0,39,DAP
|
||||
26,52,36,Clayey,Pulses,14,0,13,20-20
|
||||
29,58,40,Red,Ground Nuts,24,0,23,28-28
|
||||
30,60,27,Loamy,Sugarcane,12,0,40,DAP
|
||||
34,65,38,Clayey,Paddy,39,0,0,Urea
|
||||
36,68,38,Sandy,Barley,7,9,30,14-35-14
|
||||
26,52,48,Loamy,Wheat,23,0,19,28-28
|
||||
28,54,35,Black,Millets,41,0,0,Urea
|
||||
30,60,61,Loamy,Cotton,8,10,31,14-35-14
|
||||
37,70,37,Clayey,Paddy,12,0,41,DAP
|
||||
25,50,26,Red,Ground Nuts,15,14,11,17-17-17
|
||||
29,58,34,Sandy,Millets,15,0,37,DAP
|
||||
27,54,30,Clayey,Pulses,13,0,13,20-20
|
||||
30,60,58,Loamy,Sugarcane,10,7,32,14-35-14
|
||||
32,62,34,Red,Tobacco,22,0,24,28-28
|
||||
34,65,60,Black,Sugarcane,35,0,0,Urea
|
||||
35,67,42,Sandy,Barley,10,0,35,DAP
|
||||
38,70,48,Loamy,Wheat,8,8,28,14-35-14
|
||||
26,52,32,Black,Oil seeds,12,0,8,20-20
|
||||
29,58,43,Clayey,Paddy,24,0,18,28-28
|
||||
30,60,29,Red,Ground Nuts,41,0,0,Urea
|
||||
33,64,51,Sandy,Maize,5,9,29,14-35-14
|
||||
34,65,31,Red,Tobacco,23,0,21,28-28
|
||||
36,68,33,Black,Oil seeds,13,0,14,20-20
|
||||
28,54,38,Clayey,Pulses,40,0,0,Urea
|
||||
30,60,47,Sandy,Barley,12,0,42,DAP
|
||||
31,62,63,Red,Cotton,11,12,15,17-17-17
|
||||
27,53,43,Black,Millets,23,0,24,28-28
|
||||
34,65,54,Loamy,Wheat,38,0,0,Urea
|
||||
29,58,37,Sandy,Millets,8,0,15,20-20
|
||||
25,50,56,Loamy,Sugarcane,11,13,15,17-17-17
|
||||
32,62,34,Red,Ground Nuts,15,0,37,DAP
|
||||
28,54,41,Clayey,Paddy,36,0,0,Urea
|
||||
30,60,49,Loamy,Wheat,13,0,9,20-20
|
||||
34,65,64,Black,Cotton,24,0,20,28-28
|
||||
28,54,47,Sandy,Barley,5,18,15,10-26-26
|
||||
27,53,35,Black,Oil seeds,37,0,0,Urea
|
||||
36,68,62,Red,Cotton,15,0,40,DAP
|
||||
34,65,57,Black,Sugarcane,9,0,13,20-20
|
||||
29,58,55,Loamy,Sugarcane,8,8,33,14-35-14
|
||||
25,50,40,Clayey,Pulses,6,19,16,10-26-26
|
||||
30,60,38,Sandy,Millets,10,0,14,20-20
|
||||
26,52,39,Clayey,Pulses,21,0,23,28-28
|
||||
31,62,32,Red,Tobacco,39,0,0,Urea
|
||||
34,65,48,Loamy,Wheat,23,0,19,28-28
|
||||
27,53,34,Black,Oil seeds,42,0,0,Urea
|
||||
33,64,31,Red,Ground Nuts,13,0,39,DAP
|
||||
29,58,42,Clayey,Paddy,9,10,22,14-35-14
|
||||
30,60,47,Sandy,Maize,22,0,21,28-28
|
||||
27,53,59,Loamy,Sugarcane,10,0,15,20-20
|
||||
26,52,36,Clayey,Pulses,7,16,20,10-26-26
|
||||
34,65,63,Red,Cotton,14,0,38,DAP
|
||||
28,54,43,Clayey,Paddy,10,8,29,14-35-14
|
||||
30,60,40,Sandy,Millets,41,0,0,Urea
|
||||
29,58,65,Black,Cotton,14,0,35,DAP
|
||||
26,52,59,Loamy,Sugarcane,11,0,9,20-20
|
||||
31,62,44,Sandy,Barley,21,0,28,28-28
|
||||
35,67,28,Clayey,Pulses,8,7,31,14-35-14
|
||||
29,58,30,Red,Tobacco,13,17,16,10-26-26
|
||||
27,53,30,Black,Millets,35,0,0,Urea
|
||||
36,68,50,Loamy,Wheat,12,18,19,10-26-26
|
||||
29,58,61,Loamy,Cotton,11,0,38,DAP
|
||||
30,60,26,Black,Oil seeds,8,9,30,14-35-14
|
||||
34,65,45,Clayey,Paddy,6,19,21,10-26-26
|
||||
36,68,41,Red,Ground Nuts,41,0,0,Urea
|
||||
28,54,25,Sandy,Maize,9,10,30,14-35-14
|
||||
25,50,32,Clayey,Pulses,24,0,19,28-28
|
||||
30,60,27,Red,Tobacco,4,17,17,10-26-26
|
||||
38,72,51,Loamy,Wheat,39,0,0,Urea
|
||||
36,60,43,Sandy,Millets,15,0,41,DAP
|
||||
29,58,57,Black,Sugarcane,12,0,10,20-20
|
|
BIN
Game1/Content/ML/MLmodel
Normal file
BIN
Game1/Content/ML/MLmodel
Normal file
Binary file not shown.
BIN
Game1/Content/ML/MLmodelBig
Normal file
BIN
Game1/Content/ML/MLmodelBig
Normal file
Binary file not shown.
3
Game1/Content/ML/report
Normal file
3
Game1/Content/ML/report
Normal file
@ -0,0 +1,3 @@
|
||||
Micro Accuracy: 0.95829
|
||||
LogLoss Average: 0.100171
|
||||
LogLoss Reduction: 0.933795
|
3
Game1/Content/ML/report_BigModel
Normal file
3
Game1/Content/ML/report_BigModel
Normal file
@ -0,0 +1,3 @@
|
||||
Micro Accuracy: 1
|
||||
LogLoss Average: 0.002345
|
||||
LogLoss Reduction: 0.998302
|
BIN
Game1/Content/MLmodel
Normal file
BIN
Game1/Content/MLmodel
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
@ -63,9 +63,7 @@ namespace Game1
|
||||
cropTypesNames[10] = "Tobacco";
|
||||
cropTypesNames[11] = "Wheat";
|
||||
|
||||
|
||||
|
||||
|
||||
Engine.init();
|
||||
|
||||
|
||||
|
||||
@ -260,7 +258,7 @@ namespace Game1
|
||||
if ((tractorUnit.getFarm().getCrop(i, j).getStatus() == 3))
|
||||
{
|
||||
spriteBatch.Draw(ProgressionBar, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 3, j * (input.getSpacingTile()), input.getTileSize() / 3, input.getTileSize()), Color.White);
|
||||
spriteBatch.Draw(ProgressionBarStatus, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 4, j * (input.getSpacingTile()) + input.getTileSize() / 3, input.getTileSize() / 4, tractorUnit.getFarm().getCrop(i, j).getCropTimerBar((input.getTileSize())) + 1), Color.White);
|
||||
spriteBatch.Draw(ProgressionBarStatus, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 4, j * (input.getSpacingTile()) + input.getTileSize() / 3, input.getTileSize() / 4, tractorUnit.getFarm().getCrop(i, j).getCropTimerBar((input.getTileSize())) + 1), new Color(tractorUnit.getFarm().getCrop(i, j).getColour()));
|
||||
}
|
||||
spriteBatch.Draw(Crops[tractorUnit.getFarm().getCrop(i, j).getCropType()], new Rectangle((int)(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 2.5), j * (input.getSpacingTile()), (int)(input.getTileSize() / 2.5), input.getTileSize() / 3), Color.White);
|
||||
}
|
||||
|
@ -88,8 +88,21 @@
|
||||
<Compile Include="Sources\Crops\CropType.cs" />
|
||||
<Compile Include="Sources\Crops\CropTypesHolder.cs" />
|
||||
<Compile Include="Sources\Crops\SoilProperties.cs" />
|
||||
<Compile Include="Sources\ML\Engine.cs" />
|
||||
<Compile Include="Sources\Objects\DayNightCycle.cs" />
|
||||
<Compile Include="Sources\Objects\Fertilizer.cs" />
|
||||
<Compile Include="Sources\Objects\FertilizerHolder.cs" />
|
||||
<Compile Include="Sources\Objects\HandleRotation.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Sources\ML\InOut\BigModelInput.cs" />
|
||||
<Compile Include="Sources\ML\InOut\BigModelOutput.cs" />
|
||||
<Compile Include="Sources\ML\MLModel.cs" />
|
||||
<Compile Include="Sources\ML\InOut\ModelOutput.cs" />
|
||||
<Compile Include="Sources\ML\InOut\ModelInput.cs" />
|
||||
<Compile Include="Sources\Objects\House.cs" />
|
||||
<Compile Include="Sources\Crops\Crops.cs" />
|
||||
<Compile Include="Sources\Crops\Farm.cs" />
|
||||
@ -130,11 +143,58 @@
|
||||
<Content Include="Content\tileunplantable.png" />
|
||||
<Content Include="Content\Tractor.png" />
|
||||
<Content Include="Icon.ico" />
|
||||
<None Include="Resources\TextFile1.txt" />
|
||||
<None Include="Sources\ML\Data\FertPredictDataset.csv" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
<None Include="app.config" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Sources\ML\Data\Fertilizer Prediction.csv" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LightGBM">
|
||||
<Version>2.3.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML.CpuMath">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML.FastTree">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.ML.LightGbm">
|
||||
<Version>1.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.CodeDom">
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Collections.Immutable">
|
||||
<Version>1.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Reflection.Emit.Lightweight">
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
|
||||
<Version>4.7.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Threading.Tasks.Dataflow">
|
||||
<Version>4.11.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="C5">
|
||||
|
84
Game1/Properties/Resources.Designer.cs
generated
Normal file
84
Game1/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,84 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Game1.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Game1.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Temparature,Humidity ,Moisture,Soil Type,Crop Type,Nitrogen,Potassium,Phosphorous,Fertilizer Name
|
||||
///26,52,38,Sandy,Maize,37,0,0,Urea
|
||||
///29,52,45,Loamy,Sugarcane,12,0,36,DAP
|
||||
///34,65,62,Black,Cotton,7,9,30,14-35-14
|
||||
///32,62,34,Red,Tobacco,22,0,20,28-28
|
||||
///28,54,46,Clayey,Paddy,35,0,0,Urea
|
||||
///26,52,35,Sandy,Barley,12,10,13,17-17-17
|
||||
///25,50,64,Red,Cotton,9,0,10,20-20
|
||||
///33,64,50,Loamy,Wheat,41,0,0,Urea
|
||||
///30,60,42,Sandy,Millets,21,0,18,28-28
|
||||
///29,58,33,Black,Oil seeds,9,7,30,14-35-14
|
||||
///27,54,28,Clayey,Pulses,13,0,40,DAP
|
||||
///31,62, [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string Fertilizer_Prediction {
|
||||
get {
|
||||
return ResourceManager.GetString("Fertilizer_Prediction", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
124
Game1/Properties/Resources.resx
Normal file
124
Game1/Properties/Resources.resx
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Fertilizer_Prediction" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\sources\ml\data\fertilizer prediction.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
</root>
|
0
Game1/Resources/TextFile1.txt
Normal file
0
Game1/Resources/TextFile1.txt
Normal file
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
class Crops
|
||||
{
|
||||
public int Status;
|
||||
private int Timer;
|
||||
private Random r;
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public void updateCrop()
|
||||
{
|
||||
if (Status != 0)
|
||||
{
|
||||
Timer--;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCropTimer()
|
||||
{
|
||||
return Timer;
|
||||
}
|
||||
|
||||
public int getStatus()
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
public void setStatus(int newStatus)
|
||||
{
|
||||
Status = newStatus;
|
||||
}
|
||||
|
||||
public void setPosition(int newx, int newy)
|
||||
{
|
||||
x = newx;
|
||||
y = newy;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ class CropTypes
|
||||
|
||||
public string[] soilType = new string[3];
|
||||
public int[] Times = new int[3];
|
||||
public string CropName;
|
||||
public float Temparature;
|
||||
public float Humidity;
|
||||
public float Moisture;
|
||||
|
@ -16,6 +16,7 @@ class CropTypesHolder
|
||||
cropTypes[0].soilType[0] = "None";
|
||||
cropTypes[0].soilType[1] = null;
|
||||
cropTypes[0].soilType[2] = null;
|
||||
cropTypes[0].CropName = "None";
|
||||
cropTypes[0].Temparature = 0f;
|
||||
cropTypes[0].Humidity = 0f;
|
||||
cropTypes[0].Moisture = 0f;
|
||||
@ -28,12 +29,13 @@ class CropTypesHolder
|
||||
cropTypes[1].soilType[0] = "Sandy";
|
||||
cropTypes[1].soilType[1] = null;
|
||||
cropTypes[1].soilType[2] = null;
|
||||
cropTypes[1].CropName = "Barley";
|
||||
cropTypes[1].Temparature = 30.1f;
|
||||
cropTypes[1].Humidity = 59.0f;
|
||||
cropTypes[1].Moisture = 41.7f;
|
||||
cropTypes[1].Nitrogen = 25 + 12.6f;
|
||||
cropTypes[1].Potassium = 14 + 5.3f;
|
||||
cropTypes[1].Phosphorous = 30 + 26.0f;
|
||||
cropTypes[1].Nitrogen = 21 + 12.6f;
|
||||
cropTypes[1].Potassium = 10 + 5.3f;
|
||||
cropTypes[1].Phosphorous = 20 + 26.0f;
|
||||
|
||||
|
||||
// Cotton
|
||||
@ -44,24 +46,26 @@ class CropTypesHolder
|
||||
cropTypes[2].Times[1] = 4;
|
||||
cropTypes[2].soilType[2] = "Loamy";
|
||||
cropTypes[2].Times[2] = 3;
|
||||
cropTypes[2].CropName = "Cotton";
|
||||
cropTypes[2].Temparature = 30.4f;
|
||||
cropTypes[2].Humidity = 59.6f;
|
||||
cropTypes[2].Moisture = 63.2f;
|
||||
cropTypes[2].Nitrogen = 25 + 16.4f;
|
||||
cropTypes[2].Potassium = 14 + 3.3f;
|
||||
cropTypes[2].Phosphorous = 30 + 23.8f;
|
||||
cropTypes[2].Nitrogen = 21 + 16.4f;
|
||||
cropTypes[2].Potassium = 10 + 3.3f;
|
||||
cropTypes[2].Phosphorous = 20 + 23.8f;
|
||||
|
||||
// Ground Nuts
|
||||
cropTypes[3] = new CropTypes();
|
||||
cropTypes[3].soilType[0] = "Red";
|
||||
cropTypes[3].soilType[1] = null;
|
||||
cropTypes[3].soilType[2] = null;
|
||||
cropTypes[3].CropName = "Ground Nuts";
|
||||
cropTypes[3].Temparature = 30.1f;
|
||||
cropTypes[3].Humidity = 59.1f;
|
||||
cropTypes[3].Moisture = 33.1f;
|
||||
cropTypes[3].Nitrogen = 25 + 23.3f;
|
||||
cropTypes[3].Potassium = 14 + 2.0f;
|
||||
cropTypes[3].Phosphorous = 30 + 21.6f;
|
||||
cropTypes[3].Nitrogen = 21 + 23.3f;
|
||||
cropTypes[3].Potassium = 10 + 2.0f;
|
||||
cropTypes[3].Phosphorous = 20 + 21.6f;
|
||||
|
||||
|
||||
// Maize
|
||||
@ -69,12 +73,13 @@ class CropTypesHolder
|
||||
cropTypes[4].soilType[0] = "Sandy";
|
||||
cropTypes[4].soilType[1] = null;
|
||||
cropTypes[4].soilType[2] = null;
|
||||
cropTypes[4].CropName = "Maize";
|
||||
cropTypes[4].Temparature = 29.0f;
|
||||
cropTypes[4].Humidity = 57.3f;
|
||||
cropTypes[4].Moisture = 42.2f;
|
||||
cropTypes[4].Nitrogen = 25 + 18.3f;
|
||||
cropTypes[4].Potassium = 14 + 5.7f;
|
||||
cropTypes[4].Phosphorous = 30 + 18.7f;
|
||||
cropTypes[4].Nitrogen = 21 + 18.3f;
|
||||
cropTypes[4].Potassium = 10 + 5.7f;
|
||||
cropTypes[4].Phosphorous = 20 + 18.7f;
|
||||
|
||||
// Millets
|
||||
cropTypes[5] = new CropTypes();
|
||||
@ -83,48 +88,52 @@ class CropTypesHolder
|
||||
cropTypes[5].soilType[1] = "Black";
|
||||
cropTypes[5].Times[0] = 4;
|
||||
cropTypes[5].soilType[2] = null;
|
||||
cropTypes[5].CropName = "Millets";
|
||||
cropTypes[5].Temparature = 29.5f;
|
||||
cropTypes[5].Humidity = 57.3f;
|
||||
cropTypes[5].Moisture = 38.5f;
|
||||
cropTypes[5].Nitrogen = 25 + 23.2f;
|
||||
cropTypes[5].Potassium = 14 + 0.1f;
|
||||
cropTypes[5].Phosphorous = 30 + 14.4f;
|
||||
cropTypes[5].Nitrogen = 21 + 23.2f;
|
||||
cropTypes[5].Potassium = 10 + 0.1f;
|
||||
cropTypes[5].Phosphorous = 20 + 14.4f;
|
||||
|
||||
//Oil Seeds
|
||||
cropTypes[6] = new CropTypes();
|
||||
cropTypes[6].soilType[0] = "Black";
|
||||
cropTypes[6].soilType[1] = null;
|
||||
cropTypes[6].soilType[2] = null;
|
||||
cropTypes[6].CropName = "Oil Seeds";
|
||||
cropTypes[6].Temparature = 30.3f;
|
||||
cropTypes[6].Humidity = 59.1f;
|
||||
cropTypes[6].Moisture = 32.1f;
|
||||
cropTypes[6].Nitrogen = 25 + 19.0f;
|
||||
cropTypes[6].Potassium = 14 + 2.3f;
|
||||
cropTypes[6].Phosphorous = 30 + 17.3f;
|
||||
cropTypes[6].Nitrogen = 21 + 19.0f;
|
||||
cropTypes[6].Potassium = 10 + 2.3f;
|
||||
cropTypes[6].Phosphorous = 20 + 17.3f;
|
||||
|
||||
//Paddys
|
||||
cropTypes[7] = new CropTypes();
|
||||
cropTypes[7].soilType[0] = "Clayey";
|
||||
cropTypes[7].soilType[1] = null;
|
||||
cropTypes[7].soilType[2] = null;
|
||||
cropTypes[7].CropName = "Paddys";
|
||||
cropTypes[7].Temparature = 31.2f;
|
||||
cropTypes[7].Humidity = 60.4f;
|
||||
cropTypes[7].Moisture = 41.5f;
|
||||
cropTypes[7].Nitrogen = 25 + 20.8f;
|
||||
cropTypes[7].Potassium = 14 + 3.7f;
|
||||
cropTypes[7].Phosphorous = 30 + 16.3f;
|
||||
cropTypes[7].Nitrogen = 21 + 20.8f;
|
||||
cropTypes[7].Potassium = 10 + 3.7f;
|
||||
cropTypes[7].Phosphorous = 20 + 16.3f;
|
||||
|
||||
//Pulses
|
||||
cropTypes[8] = new CropTypes();
|
||||
cropTypes[8].soilType[0] = "Clayey";
|
||||
cropTypes[8].soilType[1] = null;
|
||||
cropTypes[8].soilType[2] = null;
|
||||
cropTypes[8].CropName = "Pulses";
|
||||
cropTypes[8].Temparature = 27.8f;
|
||||
cropTypes[8].Humidity = 54.9f;
|
||||
cropTypes[8].Moisture = 34.1f;
|
||||
cropTypes[8].Nitrogen = 25 + 18.4f;
|
||||
cropTypes[8].Potassium = 14 + 4.2f;
|
||||
cropTypes[8].Phosphorous = 30 + 17.5f;
|
||||
cropTypes[8].Nitrogen = 21 + 18.4f;
|
||||
cropTypes[8].Potassium = 10 + 4.2f;
|
||||
cropTypes[8].Phosphorous = 20 + 17.5f;
|
||||
|
||||
//Sugarcane
|
||||
cropTypes[9] = new CropTypes();
|
||||
@ -133,12 +142,13 @@ class CropTypesHolder
|
||||
cropTypes[9].soilType[1] = "Black";
|
||||
cropTypes[9].Times[0] = 4;
|
||||
cropTypes[9].soilType[2] = null;
|
||||
cropTypes[9].CropName = "Sugarcane";
|
||||
cropTypes[9].Temparature = 30.0f;
|
||||
cropTypes[9].Humidity = 58.6f;
|
||||
cropTypes[9].Moisture = 51.2f;
|
||||
cropTypes[9].Nitrogen = 25 + 14.6f;
|
||||
cropTypes[9].Potassium = 14 + 4.2f;
|
||||
cropTypes[9].Phosphorous = 30 + 17.6f;
|
||||
cropTypes[9].Nitrogen = 21 + 14.6f;
|
||||
cropTypes[9].Potassium = 10 + 4.2f;
|
||||
cropTypes[9].Phosphorous = 20 + 17.6f;
|
||||
|
||||
|
||||
//Tobacco
|
||||
@ -146,12 +156,13 @@ class CropTypesHolder
|
||||
cropTypes[10].soilType[0] = "Red";
|
||||
cropTypes[10].soilType[1] = null;
|
||||
cropTypes[10].soilType[2] = null;
|
||||
cropTypes[10].CropName = "Tobacco";
|
||||
cropTypes[10].Temparature = 31.9f;
|
||||
cropTypes[10].Humidity = 62.4f;
|
||||
cropTypes[10].Moisture = 31.6f;
|
||||
cropTypes[10].Nitrogen = 25 + 19.1f;
|
||||
cropTypes[10].Potassium = 14 + 4.9f;
|
||||
cropTypes[10].Phosphorous = 30 + 19.3f;
|
||||
cropTypes[10].Nitrogen = 21 + 19.1f;
|
||||
cropTypes[10].Potassium = 10 + 4.9f;
|
||||
cropTypes[10].Phosphorous = 20 + 19.3f;
|
||||
|
||||
|
||||
//Wheat
|
||||
@ -159,12 +170,13 @@ class CropTypesHolder
|
||||
cropTypes[11].soilType[0] = "Loamy";
|
||||
cropTypes[11].soilType[1] = null;
|
||||
cropTypes[11].soilType[2] = null;
|
||||
cropTypes[11].CropName = "Wheat";
|
||||
cropTypes[11].Temparature = 33.1f;
|
||||
cropTypes[11].Humidity = 63.8f;
|
||||
cropTypes[11].Moisture = 50.0f;
|
||||
cropTypes[11].Nitrogen = 25 + 23.3f;
|
||||
cropTypes[11].Potassium = 14 + 2.9f;
|
||||
cropTypes[11].Phosphorous = 30 + 14.4f;
|
||||
cropTypes[11].Nitrogen = 21 + 23.3f;
|
||||
cropTypes[11].Potassium = 10 + 2.9f;
|
||||
cropTypes[11].Phosphorous = 20 + 14.4f;
|
||||
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,49 @@ class Crops
|
||||
}
|
||||
}
|
||||
|
||||
public float getSpeedFactor(float tractorSpeed)
|
||||
{
|
||||
return (1f * tractorSpeed) / getCostOnMovement();
|
||||
}
|
||||
|
||||
public SoilProperties getSoilProperties()
|
||||
{
|
||||
return soilProperties;
|
||||
}
|
||||
|
||||
public void Fertilize(Fertilizer fertilizer)
|
||||
{
|
||||
soilProperties.Nitrogen += fertilizer.Nitrogen;
|
||||
soilProperties.Phosphorous += fertilizer.Phosphorus;
|
||||
soilProperties.Potassium += fertilizer.Potassium;
|
||||
|
||||
if (soilProperties.Nitrogen > 42)
|
||||
soilProperties.Nitrogen = 42;
|
||||
if (soilProperties.Phosphorous > 42)
|
||||
soilProperties.Phosphorous = 42;
|
||||
if (soilProperties.Potassium > 19)
|
||||
soilProperties.Potassium = 19;
|
||||
|
||||
}
|
||||
|
||||
public bool isSaturated()
|
||||
{
|
||||
if (soilProperties.Nitrogen > 40 && (soilProperties.Phosphorous > 40 || soilProperties.Potassium > 17))
|
||||
return true;
|
||||
if (soilProperties.Phosphorous > 40 && soilProperties.Potassium > 17)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool isSaturated(int threshold)
|
||||
{
|
||||
if (soilProperties.Nitrogen > 40 - threshold && (soilProperties.Phosphorous > 40 - threshold || soilProperties.Potassium > 17 - (threshold * 17/40)))
|
||||
return true;
|
||||
if (soilProperties.Phosphorous > 40 - threshold && soilProperties.Potassium > 17 - (threshold *17/40))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getCropTimer()
|
||||
{
|
||||
return Timer;
|
||||
@ -70,7 +108,7 @@ class Crops
|
||||
// Changes the time required for the crops to be harvestable
|
||||
public void setCropTimer()
|
||||
{
|
||||
if (cropType == 0) // Carrots
|
||||
if (cropType == 1) // Barley
|
||||
{
|
||||
Timer = 300;
|
||||
fullTimer = Timer;
|
||||
@ -106,19 +144,51 @@ class Crops
|
||||
{
|
||||
if (cropType == 0)
|
||||
{
|
||||
return 15; //Carrots
|
||||
return 16; //Barley
|
||||
}
|
||||
else if (cropType == 1)
|
||||
if (cropType == 1)
|
||||
{
|
||||
return 30; //Wheat
|
||||
return 16; //Barley
|
||||
}
|
||||
else if (cropType == 2)
|
||||
{
|
||||
return 40; //Berries
|
||||
return 16; //Cotton
|
||||
}
|
||||
else if (cropType == 3)
|
||||
{
|
||||
return 16; //Ground Nuts
|
||||
}
|
||||
else if (cropType == 4)
|
||||
{
|
||||
return 16; //Maize
|
||||
}
|
||||
else if (cropType == 5)
|
||||
{
|
||||
return 16; //Millets
|
||||
}
|
||||
else if (cropType == 6)
|
||||
{
|
||||
return 16; //Oil Seeds
|
||||
}
|
||||
else if (cropType == 7)
|
||||
{
|
||||
return 16; //Paddy
|
||||
}
|
||||
else if (cropType == 8)
|
||||
{
|
||||
return 16; //Pulses
|
||||
}
|
||||
else if (cropType == 9)
|
||||
{
|
||||
return 16; //Sugarcane
|
||||
}
|
||||
else if (cropType == 10)
|
||||
{
|
||||
return 16; //Wheat
|
||||
}
|
||||
else
|
||||
{
|
||||
return 50; //Fruit Trees
|
||||
return 16; //Tobacco
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,15 +198,15 @@ class Crops
|
||||
|
||||
if (soilProperties.Nitrogen > 4.0f)
|
||||
{
|
||||
soilProperties.Nitrogen = soilProperties.Nitrogen - soilProperties.NitrogenDegradeRate;
|
||||
soilProperties.Nitrogen = soilProperties.Nitrogen - (soilProperties.NitrogenDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
||||
}
|
||||
if (soilProperties.Phosphorous > 0.1f)
|
||||
{
|
||||
soilProperties.Phosphorous = soilProperties.Phosphorous - soilProperties.PhosphorousDegradeRate;
|
||||
soilProperties.Phosphorous = soilProperties.Phosphorous - (soilProperties.PhosphorousDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
||||
}
|
||||
if (soilProperties.Potassium > 0.1f)
|
||||
{
|
||||
soilProperties.Potassium = soilProperties.Potassium - soilProperties.PotassiumDegradeRate;
|
||||
soilProperties.Potassium = soilProperties.Potassium - (soilProperties.PotassiumDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
||||
}
|
||||
|
||||
}
|
||||
@ -194,26 +264,58 @@ class Crops
|
||||
return housePos;
|
||||
}
|
||||
|
||||
public bool belowCapacity()
|
||||
{
|
||||
return ((int)(soilProperties.Nitrogen + soilProperties.Potassium + soilProperties.Phosphorous)) < soilProperties.Capacity;
|
||||
}
|
||||
|
||||
public Vector4 getColour()
|
||||
{
|
||||
float r, g, b, a;
|
||||
float productionRate, overhead;
|
||||
|
||||
if (ProductionRate > 1.0f)
|
||||
{
|
||||
productionRate = 1.0f;
|
||||
overhead = ProductionRate - 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
productionRate = ProductionRate;
|
||||
overhead = 0.0f;
|
||||
}
|
||||
|
||||
r = (1.0f - productionRate) * 4;
|
||||
g = 0.0f + productionRate;
|
||||
b = 0.0f + overhead * 3;
|
||||
a = 255;
|
||||
|
||||
return new Vector4(r, g, b, a);
|
||||
}
|
||||
|
||||
public float getProductionRate(CropTypes Sample)
|
||||
{
|
||||
ProductionRate = 1;
|
||||
float min = 1.0f;
|
||||
if (DataSet != null)
|
||||
{
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, Sample.Temparature));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, Sample.Moisture));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, Sample.Humidity));
|
||||
//ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, Sample.Temparature));
|
||||
//ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, Sample.Moisture));
|
||||
//ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, Sample.Humidity));
|
||||
min = Math.Min(compareToDatset(soilProperties.Phosphorous, Sample.Phosphorous), Math.Min(compareToDatset(soilProperties.Potassium, Sample.Potassium), compareToDatset(soilProperties.Nitrogen, Sample.Nitrogen)));
|
||||
ProductionRate = ProductionRate + (ProductionRate * min);
|
||||
//ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Phosphorous, Sample.Phosphorous));
|
||||
//ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Potassium, Sample.Potassium));
|
||||
//ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Nitrogen, Sample.Nitrogen));
|
||||
if (ProductionRate < 0)
|
||||
{
|
||||
ProductionRate = 0;
|
||||
}
|
||||
ProductionRate = ProductionRate / 10;
|
||||
ProductionRate = ProductionRate / 1.5f;
|
||||
}
|
||||
ProductionRate = (float)Math.Pow(ProductionRate, 2.5f);
|
||||
return ProductionRate;
|
||||
}
|
||||
|
||||
public float getProductionRate()
|
||||
{
|
||||
return ProductionRate;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ class Farm
|
||||
private Random r;
|
||||
private CropTypesHolder PresetCrops = new CropTypesHolder();
|
||||
private int Update;
|
||||
private Astar astar = new Astar();
|
||||
|
||||
|
||||
//initializes the crops
|
||||
@ -20,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++)
|
||||
@ -39,9 +41,30 @@ 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 99; i++)
|
||||
{
|
||||
for (int j = 0; j < 99; j++)
|
||||
{
|
||||
if (crops[i, j].getStatus() == 2)
|
||||
{
|
||||
if (!astar.isReachable(crops, new Vector2((int)i, (int)j), housepos))
|
||||
{
|
||||
//crops[i, j].setStatus(1);
|
||||
dirtCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dirtCount != 0)
|
||||
init(Size, housepos);
|
||||
}
|
||||
|
||||
public void updateFarm(Vector2 Size)
|
||||
{
|
||||
@ -76,6 +99,7 @@ class Farm
|
||||
}
|
||||
else if (crops[x, y].getStatus() == 2)
|
||||
{
|
||||
|
||||
crops[x, y].setStatus(3);
|
||||
crops[x, y].setCropTimer();
|
||||
}
|
||||
@ -111,9 +135,12 @@ class Farm
|
||||
for (int i = 0; i < Size.X; i++)
|
||||
{
|
||||
for (int j = 0; j < Size.X; j++)
|
||||
{
|
||||
if (crops[i, j].getStatus() != 3)
|
||||
{
|
||||
int x = getHighestProductionRate(i, j);
|
||||
crops[i,j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
||||
crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class SoilProperties
|
||||
public float NitrogenDegradeRate = 1.0f - (1.0f/55 * 40);
|
||||
public float PotassiumDegradeRate = 1.0f - (1.0f/28 * 23);
|
||||
public float PhosphorousDegradeRate = 1.0f - (1.0f/60 * 37);
|
||||
public int Capacity = 80;
|
||||
|
||||
public void setSoilProperties()
|
||||
{
|
||||
@ -47,9 +48,9 @@ class SoilProperties
|
||||
Temperature = GetRandomNumber(22, 30);
|
||||
Humidity = Temperature * GetRandomNumber(1.9, 2.1);
|
||||
Moisture = GetRandomNumber(20, 70);
|
||||
Nitrogen = GetRandomNumber(4 , 55);
|
||||
Potassium = GetRandomNumber(0.01f, 28);
|
||||
Phosphorous = GetRandomNumber(0.01f, 60);
|
||||
Nitrogen = GetRandomNumber(4 , 42); //was 4, 60
|
||||
Potassium = GetRandomNumber(0.01f, 19); // was 0, 28
|
||||
Phosphorous = GetRandomNumber(0.01f, 42); // was 0, 60
|
||||
}
|
||||
|
||||
public float GetRandomNumber(double minimum, double maximum)
|
||||
|
@ -1,91 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
class Farm
|
||||
{
|
||||
private Crops[,] crops;
|
||||
private Random r;
|
||||
|
||||
public void init(Vector2 Size)
|
||||
{
|
||||
r = new Random();
|
||||
crops = new Crops[100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 56) - 125 / 56];
|
||||
for (int i = 0; i < Size.X; i++)
|
||||
{
|
||||
for (int j = 0; j < Size.Y; j++)
|
||||
{
|
||||
int x = r.Next(0, 2);
|
||||
crops[i, j] = new Crops();
|
||||
crops[i, j].Status = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFarm(Vector2 Size)
|
||||
{
|
||||
for (int i = 0; i > Size.X; i++)
|
||||
{
|
||||
for (int j = 0; j > Size.Y; j++)
|
||||
{
|
||||
crops[i, j].updateCrop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setCropStatus(float xfloat, float yfloat, int Spacing)
|
||||
{
|
||||
int x = (int)xfloat / Spacing;
|
||||
int y = (int)yfloat / Spacing;
|
||||
if (crops[x, y].Status == 3)
|
||||
{
|
||||
crops[x, y].Status = 1;
|
||||
}
|
||||
else if(crops[x, y].Status == 0)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
else if (crops[x, y].Status == 1)
|
||||
{
|
||||
crops[x, y].Status = 2;
|
||||
}
|
||||
else if (crops[x, y].Status == 2)
|
||||
{
|
||||
crops[x, y].Status = 3;
|
||||
}
|
||||
}
|
||||
|
||||
public Crops getCrop(int x, int y)
|
||||
{
|
||||
return crops[x,y];
|
||||
}
|
||||
|
||||
public Crops[,] getCrops()
|
||||
{
|
||||
return crops;
|
||||
}
|
||||
|
||||
public void updateSize(Vector2 Size, int tileSize, int Spacing)
|
||||
{
|
||||
|
||||
for (int i = 0; i < (int)Size.X; i++)
|
||||
{
|
||||
for (int j = 0; j < (int)Size.Y; j++)
|
||||
{
|
||||
crops[i, j].x = (tileSize + Spacing) * i;
|
||||
crops[i, j].y = (tileSize + Spacing) * j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string getSize()
|
||||
{
|
||||
return crops[1, 1].x.ToString();
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
class House
|
||||
{
|
||||
|
||||
private Rectangle housePos;
|
||||
private Vector2 pos;
|
||||
private Random r = new Random();
|
||||
|
||||
public void init(int tileSize, int Spacing)
|
||||
{
|
||||
int x = r.Next(0, 8);
|
||||
int y = r.Next(0, 8);
|
||||
|
||||
pos = new Vector2(x, y);
|
||||
housePos = new Rectangle((x * tileSize + Spacing), y * (tileSize + Spacing), tileSize, tileSize);
|
||||
}
|
||||
|
||||
public void updateRectangle(Vector2 Size, int tileSize)
|
||||
{
|
||||
if (pos.X + 1 > Size.X)
|
||||
{
|
||||
pos = new Vector2(pos.X - 1, pos.Y);
|
||||
}
|
||||
if (pos.Y + 1 > Size.Y)
|
||||
{
|
||||
pos = new Vector2(pos.X, pos.Y - 1);
|
||||
}
|
||||
housePos = new Rectangle((int)pos.X * (tileSize + 1), (int)pos.Y * (tileSize + 1), tileSize, tileSize);
|
||||
}
|
||||
|
||||
|
||||
public Rectangle GetRectangle()
|
||||
{
|
||||
return housePos;
|
||||
}
|
||||
|
||||
public Vector2 getVector()
|
||||
{
|
||||
return new Vector2(housePos.X, housePos.Y);
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
|
||||
|
||||
class Input
|
||||
{
|
||||
private KeyboardState state = Keyboard.GetState();
|
||||
private GraphicsDeviceManager graphics;
|
||||
private Vector2 Size;
|
||||
private int tileSize;
|
||||
private int Spacing;
|
||||
|
||||
public void init(GraphicsDeviceManager Graphics, Vector2 size, int TileSize, int SPacing)
|
||||
{
|
||||
graphics = Graphics;
|
||||
tileSize = TileSize;
|
||||
Spacing = SPacing;
|
||||
Size = size;
|
||||
}
|
||||
|
||||
public int changeSpeed(int speed)
|
||||
{
|
||||
KeyboardState state = Keyboard.GetState();
|
||||
if (state.IsKeyDown(Keys.Right))
|
||||
{
|
||||
speed++;
|
||||
}
|
||||
|
||||
if (state.IsKeyDown(Keys.Left) && speed > 0)
|
||||
{
|
||||
speed--;
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
private Vector2 changeSize()
|
||||
{
|
||||
KeyboardState state = Keyboard.GetState();
|
||||
if (state.IsKeyDown(Keys.D) && Size.X < 100)
|
||||
{
|
||||
Size.X++;
|
||||
graphics.PreferredBackBufferWidth = (tileSize + Spacing) * (int)Size.X - Spacing;
|
||||
}
|
||||
|
||||
if (state.IsKeyDown(Keys.A) && Size.X > 2)
|
||||
{
|
||||
Size.X--;
|
||||
graphics.PreferredBackBufferWidth = (tileSize + Spacing) * (int)Size.X - Spacing;
|
||||
}
|
||||
|
||||
if (state.IsKeyDown(Keys.W) && Size.Y < (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize)
|
||||
{
|
||||
Size.Y++;
|
||||
graphics.PreferredBackBufferHeight = (tileSize + Spacing) * (int)Size.Y - Spacing + 100;
|
||||
}
|
||||
|
||||
if (state.IsKeyDown(Keys.S) && Size.Y > 2)
|
||||
{
|
||||
Size.Y--;
|
||||
graphics.PreferredBackBufferHeight = (tileSize + Spacing) * (int)Size.Y - Spacing + 100;
|
||||
}
|
||||
return Size;
|
||||
}
|
||||
|
||||
public void controlWindowSize()
|
||||
{
|
||||
if (Size.X * tileSize + 5 > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width)
|
||||
{
|
||||
tileSize--;
|
||||
}
|
||||
if (Size.X * tileSize - 5 < GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width && tileSize < 56)
|
||||
{
|
||||
tileSize++;
|
||||
}
|
||||
changeSize();
|
||||
graphics.ApplyChanges();
|
||||
}
|
||||
|
||||
public int getTileSize()
|
||||
{
|
||||
return tileSize;
|
||||
}
|
||||
|
||||
public int getSpacing()
|
||||
{
|
||||
return Spacing;
|
||||
}
|
||||
|
||||
public Vector2 getSize()
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
public void setTileSize(int newTileSize)
|
||||
{
|
||||
tileSize = newTileSize;
|
||||
}
|
||||
}
|
1600
Game1/Sources/ML/Data/FertPredictDataset.csv
Normal file
1600
Game1/Sources/ML/Data/FertPredictDataset.csv
Normal file
File diff suppressed because it is too large
Load Diff
100
Game1/Sources/ML/Data/Fertilizer Prediction.csv
Normal file
100
Game1/Sources/ML/Data/Fertilizer Prediction.csv
Normal file
@ -0,0 +1,100 @@
|
||||
Temparature,Humidity ,Moisture,Soil Type,Crop Type,Nitrogen,Potassium,Phosphorous,Fertilizer Name
|
||||
26,52,38,Sandy,Maize,37,0,0,Urea
|
||||
29,52,45,Loamy,Sugarcane,12,0,36,DAP
|
||||
34,65,62,Black,Cotton,7,9,30,14-35-14
|
||||
32,62,34,Red,Tobacco,22,0,20,28-28
|
||||
28,54,46,Clayey,Paddy,35,0,0,Urea
|
||||
26,52,35,Sandy,Barley,12,10,13,17-17-17
|
||||
25,50,64,Red,Cotton,9,0,10,20-20
|
||||
33,64,50,Loamy,Wheat,41,0,0,Urea
|
||||
30,60,42,Sandy,Millets,21,0,18,28-28
|
||||
29,58,33,Black,Oil seeds,9,7,30,14-35-14
|
||||
27,54,28,Clayey,Pulses,13,0,40,DAP
|
||||
31,62,48,Sandy,Maize,14,15,12,17-17-17
|
||||
25,50,65,Loamy,Cotton,36,0,0,Urea
|
||||
32,62,41,Clayey,Paddy,24,0,22,28-28
|
||||
26,52,31,Red,Ground Nuts,14,0,41,DAP
|
||||
31,62,49,Black,Sugarcane,10,13,14,17-17-17
|
||||
33,64,34,Clayey,Pulses,38,0,0,Urea
|
||||
25,50,39,Sandy,Barley,21,0,19,28-28
|
||||
28,54,65,Black,Cotton,39,0,0,Urea
|
||||
29,58,52,Loamy,Wheat,13,0,36,DAP
|
||||
30,60,44,Sandy,Millets,10,0,9,20-20
|
||||
34,65,53,Loamy,Sugarcane,12,14,12,17-17-17
|
||||
35,68,33,Red,Tobacco,11,0,37,DAP
|
||||
28,54,37,Black,Millets,36,0,0,Urea
|
||||
33,64,39,Clayey,Paddy,13,0,10,20-20
|
||||
26,52,44,Sandy,Maize,23,0,20,28-28
|
||||
30,60,63,Red,Cotton,9,9,29,14-35-14
|
||||
32,62,30,Loamy,Sugarcane,38,0,0,Urea
|
||||
37,70,32,Black,Oil seeds,12,0,39,DAP
|
||||
26,52,36,Clayey,Pulses,14,0,13,20-20
|
||||
29,58,40,Red,Ground Nuts,24,0,23,28-28
|
||||
30,60,27,Loamy,Sugarcane,12,0,40,DAP
|
||||
34,65,38,Clayey,Paddy,39,0,0,Urea
|
||||
36,68,38,Sandy,Barley,7,9,30,14-35-14
|
||||
26,52,48,Loamy,Wheat,23,0,19,28-28
|
||||
28,54,35,Black,Millets,41,0,0,Urea
|
||||
30,60,61,Loamy,Cotton,8,10,31,14-35-14
|
||||
37,70,37,Clayey,Paddy,12,0,41,DAP
|
||||
25,50,26,Red,Ground Nuts,15,14,11,17-17-17
|
||||
29,58,34,Sandy,Millets,15,0,37,DAP
|
||||
27,54,30,Clayey,Pulses,13,0,13,20-20
|
||||
30,60,58,Loamy,Sugarcane,10,7,32,14-35-14
|
||||
32,62,34,Red,Tobacco,22,0,24,28-28
|
||||
34,65,60,Black,Sugarcane,35,0,0,Urea
|
||||
35,67,42,Sandy,Barley,10,0,35,DAP
|
||||
38,70,48,Loamy,Wheat,8,8,28,14-35-14
|
||||
26,52,32,Black,Oil seeds,12,0,8,20-20
|
||||
29,58,43,Clayey,Paddy,24,0,18,28-28
|
||||
30,60,29,Red,Ground Nuts,41,0,0,Urea
|
||||
33,64,51,Sandy,Maize,5,9,29,14-35-14
|
||||
34,65,31,Red,Tobacco,23,0,21,28-28
|
||||
36,68,33,Black,Oil seeds,13,0,14,20-20
|
||||
28,54,38,Clayey,Pulses,40,0,0,Urea
|
||||
30,60,47,Sandy,Barley,12,0,42,DAP
|
||||
31,62,63,Red,Cotton,11,12,15,17-17-17
|
||||
27,53,43,Black,Millets,23,0,24,28-28
|
||||
34,65,54,Loamy,Wheat,38,0,0,Urea
|
||||
29,58,37,Sandy,Millets,8,0,15,20-20
|
||||
25,50,56,Loamy,Sugarcane,11,13,15,17-17-17
|
||||
32,62,34,Red,Ground Nuts,15,0,37,DAP
|
||||
28,54,41,Clayey,Paddy,36,0,0,Urea
|
||||
30,60,49,Loamy,Wheat,13,0,9,20-20
|
||||
34,65,64,Black,Cotton,24,0,20,28-28
|
||||
28,54,47,Sandy,Barley,5,18,15,10-26-26
|
||||
27,53,35,Black,Oil seeds,37,0,0,Urea
|
||||
36,68,62,Red,Cotton,15,0,40,DAP
|
||||
34,65,57,Black,Sugarcane,9,0,13,20-20
|
||||
29,58,55,Loamy,Sugarcane,8,8,33,14-35-14
|
||||
25,50,40,Clayey,Pulses,6,19,16,10-26-26
|
||||
30,60,38,Sandy,Millets,10,0,14,20-20
|
||||
26,52,39,Clayey,Pulses,21,0,23,28-28
|
||||
31,62,32,Red,Tobacco,39,0,0,Urea
|
||||
34,65,48,Loamy,Wheat,23,0,19,28-28
|
||||
27,53,34,Black,Oil seeds,42,0,0,Urea
|
||||
33,64,31,Red,Ground Nuts,13,0,39,DAP
|
||||
29,58,42,Clayey,Paddy,9,10,22,14-35-14
|
||||
30,60,47,Sandy,Maize,22,0,21,28-28
|
||||
27,53,59,Loamy,Sugarcane,10,0,15,20-20
|
||||
26,52,36,Clayey,Pulses,7,16,20,10-26-26
|
||||
34,65,63,Red,Cotton,14,0,38,DAP
|
||||
28,54,43,Clayey,Paddy,10,8,29,14-35-14
|
||||
30,60,40,Sandy,Millets,41,0,0,Urea
|
||||
29,58,65,Black,Cotton,14,0,35,DAP
|
||||
26,52,59,Loamy,Sugarcane,11,0,9,20-20
|
||||
31,62,44,Sandy,Barley,21,0,28,28-28
|
||||
35,67,28,Clayey,Pulses,8,7,31,14-35-14
|
||||
29,58,30,Red,Tobacco,13,17,16,10-26-26
|
||||
27,53,30,Black,Millets,35,0,0,Urea
|
||||
36,68,50,Loamy,Wheat,12,18,19,10-26-26
|
||||
29,58,61,Loamy,Cotton,11,0,38,DAP
|
||||
30,60,26,Black,Oil seeds,8,9,30,14-35-14
|
||||
34,65,45,Clayey,Paddy,6,19,21,10-26-26
|
||||
36,68,41,Red,Ground Nuts,41,0,0,Urea
|
||||
28,54,25,Sandy,Maize,9,10,30,14-35-14
|
||||
25,50,32,Clayey,Pulses,24,0,19,28-28
|
||||
30,60,27,Red,Tobacco,4,17,17,10-26-26
|
||||
38,72,51,Loamy,Wheat,39,0,0,Urea
|
||||
36,60,43,Sandy,Millets,15,0,41,DAP
|
||||
29,58,57,Black,Sugarcane,12,0,10,20-20
|
|
36
Game1/Sources/ML/Engine.cs
Normal file
36
Game1/Sources/ML/Engine.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ML;
|
||||
|
||||
|
||||
static class Engine
|
||||
{
|
||||
private static MLContext mlContext = new MLContext(seed: 1);
|
||||
private static PredictionEngine<ModelInput, ModelOutput> PredictionEngine;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
PredictionEngine = MLModel.CreateEngine();
|
||||
}
|
||||
|
||||
public static string PredictFertilizer(Crops crop, CropTypes cropTypes)
|
||||
{
|
||||
ModelInput modelInput = new ModelInput
|
||||
{
|
||||
Temperature = crop.getSoilProperties().Temperature,
|
||||
Humidity = crop.getSoilProperties().Humidity,
|
||||
Moisture = crop.getSoilProperties().Moisture,
|
||||
Soil_Type = crop.getSoilProperties().soilType,
|
||||
Crop_Type = cropTypes.CropName,
|
||||
Nitrogen = crop.getSoilProperties().Nitrogen,
|
||||
Potassium = crop.getSoilProperties().Potassium,
|
||||
Phosporous = crop.getSoilProperties().Phosphorous
|
||||
};
|
||||
|
||||
return PredictionEngine.Predict(modelInput).Prediction;
|
||||
}
|
||||
}
|
||||
|
42
Game1/Sources/ML/InOut/BigModelInput.cs
Normal file
42
Game1/Sources/ML/InOut/BigModelInput.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ML.Data;
|
||||
|
||||
|
||||
class BigModelInput
|
||||
{
|
||||
[ColumnName("Ca"), LoadColumn(0)]
|
||||
public float Ca { get; set; }
|
||||
|
||||
[ColumnName("Mg"), LoadColumn(1)]
|
||||
public float Mg { get; set; }
|
||||
|
||||
[ColumnName("K"), LoadColumn(2)]
|
||||
public float K { get; set; }
|
||||
|
||||
[ColumnName("S"), LoadColumn(3)]
|
||||
public float S { get; set; }
|
||||
|
||||
[ColumnName("N"), LoadColumn(4)]
|
||||
public float N { get; set; }
|
||||
|
||||
[ColumnName("Lime"), LoadColumn(5)]
|
||||
public float Lime { get; set; }
|
||||
|
||||
[ColumnName("C"), LoadColumn(6)]
|
||||
public float C { get; set; }
|
||||
|
||||
[ColumnName("P"), LoadColumn(7)]
|
||||
public float P { get; set; }
|
||||
|
||||
[ColumnName("Moisture"), LoadColumn(8)]
|
||||
public float Moisture { get; set; }
|
||||
|
||||
[ColumnName("Class"), LoadColumn(9)]
|
||||
public float Class { get; set; }
|
||||
|
||||
}
|
||||
|
13
Game1/Sources/ML/InOut/BigModelOutput.cs
Normal file
13
Game1/Sources/ML/InOut/BigModelOutput.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ML.Data;
|
||||
|
||||
class BigModelOutput
|
||||
{
|
||||
[ColumnName("PredictedLabel")]
|
||||
public float Prediction { get; set; }
|
||||
}
|
||||
|
39
Game1/Sources/ML/InOut/ModelInput.cs
Normal file
39
Game1/Sources/ML/InOut/ModelInput.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ML;
|
||||
using Microsoft.ML.Data;
|
||||
|
||||
|
||||
class ModelInput
|
||||
{
|
||||
[ColumnName("Temperature"), LoadColumn(0)]
|
||||
public float Temperature { get; set; }
|
||||
|
||||
[ColumnName("Humidity"), LoadColumn(1)]
|
||||
public float Humidity { get; set; }
|
||||
|
||||
[ColumnName("Moisture"), LoadColumn(2)]
|
||||
public float Moisture { get; set; }
|
||||
|
||||
[ColumnName("Soil_Type"), LoadColumn(3)]
|
||||
public String Soil_Type { get; set; }
|
||||
|
||||
[ColumnName("Crop_Type"), LoadColumn(4)]
|
||||
public String Crop_Type { get; set; }
|
||||
|
||||
[ColumnName("Nitrogen"), LoadColumn(5)]
|
||||
public float Nitrogen { get; set; }
|
||||
|
||||
[ColumnName("Potassium"), LoadColumn(6)]
|
||||
public float Potassium { get; set; }
|
||||
|
||||
[ColumnName("Phosphorous"), LoadColumn(7)]
|
||||
public float Phosporous { get; set; }
|
||||
|
||||
[ColumnName("Fertilizer_Name"), LoadColumn(8)]
|
||||
public String Fertilizer_Name { get; set; }
|
||||
}
|
||||
|
15
Game1/Sources/ML/InOut/ModelOutput.cs
Normal file
15
Game1/Sources/ML/InOut/ModelOutput.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ML.Data;
|
||||
|
||||
class ModelOutput
|
||||
{
|
||||
[ColumnName("PredictedLabel")]
|
||||
public String Prediction { get; set; }
|
||||
//public float[] Score { get; set; }
|
||||
|
||||
}
|
||||
|
167
Game1/Sources/ML/MLModel.cs
Normal file
167
Game1/Sources/ML/MLModel.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ML;
|
||||
using Microsoft.ML.Data;
|
||||
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";
|
||||
|
||||
// Loading data, creatin and saving ML model for smaller dataset (100)
|
||||
public static void CreateModel()
|
||||
{
|
||||
|
||||
IDataView trainingDataView = mlContext.Data.LoadFromTextFile<ModelInput>(
|
||||
path: path,
|
||||
hasHeader: true,
|
||||
separatorChar: ',',
|
||||
allowQuoting: true,
|
||||
allowSparse: false);
|
||||
|
||||
ModelInput sample = mlContext.Data.CreateEnumerable<ModelInput>(trainingDataView, false).ElementAt(0);
|
||||
ITransformer MLModel = BuildAndTrain(mlContext, trainingDataView, sample, report);
|
||||
SaveModel(mlContext, MLModel, modelpath, trainingDataView.Schema);
|
||||
}
|
||||
|
||||
// ... for bigger dataset (1600)
|
||||
public static void CreateBigModel()
|
||||
{
|
||||
|
||||
IDataView trainingDataView = mlContext.Data.LoadFromTextFile<BigModelInput>(
|
||||
path: pathBig,
|
||||
hasHeader: true,
|
||||
separatorChar: ',',
|
||||
allowQuoting: true,
|
||||
allowSparse: false);
|
||||
|
||||
BigModelInput sample = mlContext.Data.CreateEnumerable<BigModelInput>(trainingDataView, false).ElementAt(0);
|
||||
ITransformer MLModel = BuildAndTrain(mlContext, trainingDataView, sample, reportBig);
|
||||
SaveModel(mlContext, MLModel, modelpathBig, trainingDataView.Schema);
|
||||
}
|
||||
|
||||
// Building and training ML model, very small dataset (100 entries)
|
||||
public static ITransformer BuildAndTrain(MLContext mLContext, IDataView trainingDataView, ModelInput sample, string reportPath)
|
||||
{
|
||||
|
||||
var options = new LightGbmMulticlassTrainer.Options
|
||||
{
|
||||
MaximumBinCountPerFeature = 8,
|
||||
LearningRate = 0.00025,
|
||||
NumberOfIterations = 40000,
|
||||
NumberOfLeaves = 10,
|
||||
LabelColumnName = "Fertilizer_NameF",
|
||||
FeatureColumnName = "Features",
|
||||
|
||||
Booster = new DartBooster.Options()
|
||||
{
|
||||
MaximumTreeDepth = 10
|
||||
}
|
||||
};
|
||||
|
||||
var pipeline = mlContext.Transforms
|
||||
.Text.FeaturizeText("Soil_TypeF", "Soil_Type")
|
||||
.Append(mlContext.Transforms.Text.FeaturizeText("Crop_TypeF", "Crop_Type"))
|
||||
.Append(mlContext.Transforms.Concatenate("Features", "Temperature", "Humidity", "Moisture", "Soil_TypeF", "Crop_TypeF", "Nitrogen", "Potassium", "Phosphorous"))
|
||||
.Append(mlContext.Transforms.Conversion.MapValueToKey("Fertilizer_NameF", "Fertilizer_Name"), TransformerScope.TrainTest)
|
||||
.AppendCacheCheckpoint(mLContext)
|
||||
.Append(mLContext.MulticlassClassification.Trainers.LightGbm(options))
|
||||
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel", "PredictedLabel"));
|
||||
|
||||
Evaluate(mlContext, trainingDataView, pipeline, 10, reportPath, "Fertilizer_NameF");
|
||||
ITransformer MLModel = pipeline.Fit(trainingDataView);
|
||||
|
||||
return MLModel;
|
||||
}
|
||||
|
||||
//Building and training ML model, moderate size dataset (1600 entries)
|
||||
public static ITransformer BuildAndTrain(MLContext mLContext, IDataView trainingDataView, BigModelInput sample, string reportPath)
|
||||
{
|
||||
|
||||
var options = new LightGbmMulticlassTrainer.Options
|
||||
{
|
||||
MaximumBinCountPerFeature = 10,
|
||||
LearningRate = 0.001,
|
||||
NumberOfIterations = 10000,
|
||||
NumberOfLeaves = 12,
|
||||
LabelColumnName = "ClassF",
|
||||
FeatureColumnName = "Features",
|
||||
|
||||
Booster = new DartBooster.Options()
|
||||
{
|
||||
MaximumTreeDepth = 12
|
||||
}
|
||||
};
|
||||
|
||||
var pipeline = mlContext.Transforms
|
||||
.Concatenate("Features", "Ca", "Mg", "K", "S", "N", "Lime", "C", "P", "Moisture")
|
||||
.Append(mLContext.Transforms.NormalizeMinMax("Features"))
|
||||
.Append(mlContext.Transforms.Conversion.MapValueToKey("ClassF", "Class"), TransformerScope.TrainTest)
|
||||
.AppendCacheCheckpoint(mLContext)
|
||||
.Append(mLContext.MulticlassClassification.Trainers.LightGbm(options))
|
||||
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel", "PredictedLabel"));
|
||||
|
||||
Evaluate(mlContext, trainingDataView, pipeline, 8, reportPath, "ClassF");
|
||||
ITransformer MLModel = pipeline.Fit(trainingDataView);
|
||||
|
||||
return MLModel;
|
||||
}
|
||||
|
||||
public static ITransformer TrainModel(MLContext mlContext, IDataView trainingDataView, IEstimator<ITransformer> trainingPipeline)
|
||||
{
|
||||
ITransformer model = trainingPipeline.Fit(trainingDataView);
|
||||
return model;
|
||||
}
|
||||
|
||||
// Evaluate and save results to a text file
|
||||
public static void Evaluate(MLContext mlContext, IDataView trainingDataView, IEstimator<ITransformer> trainingPipeline, int folds, string reportPath, string labelColumnName)
|
||||
{
|
||||
var crossVal = mlContext.MulticlassClassification.CrossValidate(trainingDataView, trainingPipeline, numberOfFolds: folds, labelColumnName: labelColumnName);
|
||||
|
||||
var metricsInMultipleFolds = crossVal.Select(r => r.Metrics);
|
||||
|
||||
var MicroAccuracyValues = metricsInMultipleFolds.Select(m => m.MicroAccuracy);
|
||||
var LogLossValues = metricsInMultipleFolds.Select(m => m.LogLoss);
|
||||
var LogLossReductionValues = metricsInMultipleFolds.Select(m => m.LogLossReduction);
|
||||
string MicroAccuracyAverage = MicroAccuracyValues.Average().ToString("0.######");
|
||||
string LogLossAvg = LogLossValues.Average().ToString("0.######");
|
||||
string LogLossReductionAvg = LogLossReductionValues.Average().ToString("0.######");
|
||||
|
||||
var report = File.CreateText(reportPath);
|
||||
report.Write("Micro Accuracy: " + MicroAccuracyAverage +'\n'+ "LogLoss Average: " + LogLossAvg +'\n'+ "LogLoss Reduction: " + LogLossReductionAvg, 0, 0);
|
||||
report.Flush();
|
||||
report.Close();
|
||||
}
|
||||
|
||||
|
||||
public static void SaveModel(MLContext mlContext, ITransformer Model, string modelPath, DataViewSchema modelInputSchema)
|
||||
{
|
||||
mlContext.Model.Save(Model, modelInputSchema, modelPath);
|
||||
}
|
||||
|
||||
public static ITransformer LoadModel(bool isBig)
|
||||
{
|
||||
if (isBig)
|
||||
return mlContext.Model.Load(modelpathBig, out DataViewSchema inputSchema);
|
||||
else
|
||||
return mlContext.Model.Load(modelpath, out DataViewSchema inputSchema);
|
||||
}
|
||||
|
||||
public static Microsoft.ML.PredictionEngine<ModelInput, ModelOutput> CreateEngine()
|
||||
{
|
||||
ITransformer mlModel = LoadModel(false);
|
||||
return mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
15
Game1/Sources/Objects/Fertilizer.cs
Normal file
15
Game1/Sources/Objects/Fertilizer.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
class Fertilizer
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public float Nitrogen { get; set; }
|
||||
public float Phosphorus { get; set; }
|
||||
public float Potassium { get; set; }
|
||||
}
|
181
Game1/Sources/Objects/FertilizerHolder.cs
Normal file
181
Game1/Sources/Objects/FertilizerHolder.cs
Normal file
@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
class FertilizerHolder
|
||||
{
|
||||
private Fertilizer[] FertilizerType = new Fertilizer[8];
|
||||
|
||||
public void init()
|
||||
{
|
||||
/*
|
||||
FertilizerType[0] = new Fertilizer
|
||||
{
|
||||
ID = 999,
|
||||
Name = "None",
|
||||
Nitrogen = 0.0f / 5,
|
||||
Phosphorus = 0 * 0.436f / 5,
|
||||
Potassium = 0 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[1] = new Fertilizer
|
||||
{
|
||||
ID = 0,
|
||||
Name = "10-26-26",
|
||||
Nitrogen = 10.0f / 5,
|
||||
Phosphorus = 26 * 0.436f / 5,
|
||||
Potassium = 26 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[2] = new Fertilizer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "14-35-14",
|
||||
Nitrogen = 14.0f / 5,
|
||||
Phosphorus = 35 * 0.436f / 5,
|
||||
Potassium = 14 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[3] = new Fertilizer
|
||||
{
|
||||
ID = 2,
|
||||
Name = "17-17-17",
|
||||
Nitrogen = 17.0f / 5,
|
||||
Phosphorus = 17 * 0.436f / 5,
|
||||
Potassium = 17 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[4] = new Fertilizer
|
||||
{
|
||||
ID = 3,
|
||||
Name = "20-20",
|
||||
Nitrogen = 20.0f / 5,
|
||||
Phosphorus = 20 * 0.436f / 5,
|
||||
Potassium = 0 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[5] = new Fertilizer
|
||||
{
|
||||
ID = 4,
|
||||
Name = "28-28",
|
||||
Nitrogen = 28.0f / 5,
|
||||
Phosphorus = 28 * 0.436f / 5,
|
||||
Potassium = 0 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[6] = new Fertilizer
|
||||
{
|
||||
ID = 5,
|
||||
Name = "DAP",
|
||||
Nitrogen = 18.0f / 5,
|
||||
Phosphorus = 46 * 0.436f / 5,
|
||||
Potassium = 0 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[7] = new Fertilizer
|
||||
{
|
||||
ID = 6,
|
||||
Name = "Urea",
|
||||
Nitrogen = 46.0f / 5,
|
||||
Phosphorus = 0 * 0.436f / 5,
|
||||
Potassium = 0 * 0.83f / 5
|
||||
};
|
||||
}
|
||||
*/
|
||||
FertilizerType[0] = new Fertilizer
|
||||
{
|
||||
ID = 999,
|
||||
Name = "None",
|
||||
Nitrogen = 0.0f / 5,
|
||||
Phosphorus = 0 * 0.436f / 5,
|
||||
Potassium = 0 * 0.83f / 5
|
||||
};
|
||||
|
||||
FertilizerType[1] = new Fertilizer
|
||||
{
|
||||
ID = 0,
|
||||
Name = "10-26-26",
|
||||
Nitrogen = 17.21f / 5,
|
||||
Phosphorus = 12.14f / 5,
|
||||
Potassium = 0.64f / 5
|
||||
};
|
||||
|
||||
FertilizerType[2] = new Fertilizer
|
||||
{
|
||||
ID = 1,
|
||||
Name = "14-35-14",
|
||||
Nitrogen = 16.89f / 5,
|
||||
Phosphorus = 6.21f / 5,
|
||||
Potassium = 5.21f / 5
|
||||
};
|
||||
|
||||
FertilizerType[3] = new Fertilizer
|
||||
{
|
||||
ID = 2,
|
||||
Name = "17-17-17",
|
||||
Nitrogen = 14.92f / 5,
|
||||
Phosphorus = 14.42f / 5,
|
||||
Potassium = 3.0f / 5
|
||||
};
|
||||
|
||||
FertilizerType[4] = new Fertilizer
|
||||
{
|
||||
ID = 3,
|
||||
Name = "20-20",
|
||||
Nitrogen = 15.39f / 5,
|
||||
Phosphorus = 15.21f / 5,
|
||||
Potassium = 9.5f / 5
|
||||
};
|
||||
|
||||
FertilizerType[5] = new Fertilizer
|
||||
{
|
||||
ID = 4,
|
||||
Name = "28-28",
|
||||
Nitrogen = 9.67f / 5,
|
||||
Phosphorus = 10.47f / 5,
|
||||
Potassium = 9.5f / 5
|
||||
};
|
||||
|
||||
FertilizerType[6] = new Fertilizer
|
||||
{
|
||||
ID = 5,
|
||||
Name = "DAP",
|
||||
Nitrogen = 14.52f / 5,
|
||||
Phosphorus = 1.77f / 5,
|
||||
Potassium = 9.5f / 5
|
||||
};
|
||||
|
||||
FertilizerType[7] = new Fertilizer
|
||||
{
|
||||
ID = 6,
|
||||
Name = "Urea",
|
||||
Nitrogen = 1.81f / 5,
|
||||
Phosphorus = 21.0f / 5,
|
||||
Potassium = 9.5f / 5
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public int GetFertilizerID(string name)
|
||||
{
|
||||
foreach (Fertilizer fertilizer in FertilizerType)
|
||||
{
|
||||
if (fertilizer.Name == name)
|
||||
return fertilizer.ID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Fertilizer GetFertilizer(string name)
|
||||
{
|
||||
foreach (Fertilizer fertilizer in FertilizerType)
|
||||
{
|
||||
if (fertilizer.Name == name)
|
||||
return fertilizer;
|
||||
}
|
||||
return FertilizerType[0];
|
||||
}
|
||||
}
|
@ -1,17 +1,25 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
class HandleRotation
|
||||
{
|
||||
int rotationSpeed = 5, Rotation = 180;
|
||||
private float oldSpeed, movementSpeed;
|
||||
private Vector2 oldTile, oldPosition, oldMovementSpeed;
|
||||
private Vector2 Direction;
|
||||
|
||||
public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position)
|
||||
public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position, Crops crops, Vector2 oldDeltaPosition, Vector2 Target)
|
||||
{
|
||||
Vector2 Direction;
|
||||
if (Destination == 0)
|
||||
|
||||
if (oldSpeed != crops.getSpeedFactor(tractorSpeed))
|
||||
{
|
||||
Position = new Vector2((int)Math.Round(Position.X), (int)Math.Round(Position.Y));
|
||||
}
|
||||
if (Destination == 0) // down
|
||||
{
|
||||
if (Rotation == 0)
|
||||
{
|
||||
Direction = new Vector2(0, 1) * tractorSpeed;
|
||||
Direction = new Vector2(0, 1) * movementSpeed;
|
||||
Position = Position + Direction;
|
||||
}
|
||||
else
|
||||
@ -30,11 +38,11 @@ class HandleRotation
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Destination == 1)
|
||||
else if (Destination == 1) // up
|
||||
{
|
||||
if (Rotation == 180)
|
||||
{
|
||||
Direction = new Vector2(0, -1) * tractorSpeed;
|
||||
Direction = new Vector2(0, -1) * movementSpeed;
|
||||
Position = Position + Direction;
|
||||
}
|
||||
else
|
||||
@ -50,11 +58,11 @@ class HandleRotation
|
||||
}
|
||||
|
||||
}
|
||||
else if (Destination == 2)
|
||||
else if (Destination == 2) // right
|
||||
{
|
||||
if (Rotation == 270)
|
||||
{
|
||||
Direction = new Vector2(1, 0) * tractorSpeed;
|
||||
Direction = new Vector2(1, 0) * movementSpeed;
|
||||
Position = Position + Direction;
|
||||
}
|
||||
else
|
||||
@ -73,11 +81,11 @@ class HandleRotation
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Destination == 3)
|
||||
else if (Destination == 3) // left
|
||||
{
|
||||
if (Rotation == 90)
|
||||
{
|
||||
Direction = new Vector2(-1, 0) * tractorSpeed;
|
||||
Direction = new Vector2(-1, 0) * movementSpeed;
|
||||
Position = Position + Direction;
|
||||
}
|
||||
else
|
||||
@ -97,6 +105,12 @@ class HandleRotation
|
||||
}
|
||||
|
||||
}
|
||||
oldSpeed = crops.getSpeedFactor(tractorSpeed);
|
||||
if (oldDeltaPosition.X < 1 && oldDeltaPosition.X > -1 && oldDeltaPosition.Y < 1 && oldDeltaPosition.Y > -1)
|
||||
{
|
||||
Position = Target;
|
||||
}
|
||||
oldMovementSpeed = Direction;
|
||||
return Position;
|
||||
}
|
||||
|
||||
@ -104,4 +118,19 @@ class HandleRotation
|
||||
{
|
||||
return Rotation;
|
||||
}
|
||||
|
||||
public bool checkTile(Vector2 Position, int tileSize, int Spacing, float tractorSpeed, Crops crop)
|
||||
{
|
||||
Vector2 newTile = new Vector2((float)Math.Round(Position.X / (tileSize + Spacing)), (float)Math.Round(Position.Y / (tileSize + Spacing)));
|
||||
if (oldTile != newTile)
|
||||
{
|
||||
oldTile = newTile;
|
||||
movementSpeed = crop.getSpeedFactor(tractorSpeed);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
class Cargo
|
||||
{
|
||||
private Items[,] items = new Items[2, 30];
|
||||
private Items[,] items = new Items[2, 351];
|
||||
private int[] Count = new int[2];
|
||||
|
||||
|
||||
@ -25,17 +25,17 @@ class Cargo
|
||||
items[0, 6] = new Items("Urea", 1, 6);
|
||||
|
||||
//Crop Seed Storage
|
||||
items[1, 0] = new Items("Barley", 1, 0);
|
||||
items[1, 0] = new Items("Barley", 2, 0);
|
||||
items[1, 1] = new Items("Cotton", 1, 1);
|
||||
items[1, 2] = new Items("Ground Nuts", 1, 2);
|
||||
items[1, 3] = new Items("Maize", 1, 3);
|
||||
items[1, 4] = new Items("Millets", 1, 4);
|
||||
items[1, 5] = new Items("Oil Seeds", 1, 5);
|
||||
items[1, 6] = new Items("Paddy", 1, 6);
|
||||
items[1, 7] = new Items("Pulses", 1, 7);
|
||||
items[1, 8] = new Items("Sugarcane", 1, 8);
|
||||
items[1, 9] = new Items("Tobacco", 1, 9);
|
||||
items[1, 10] = new Items("Wheat", 1, 10);
|
||||
items[1, 2] = new Items("Ground Nuts", 5, 2);
|
||||
items[1, 3] = new Items("Maize", 3, 3);
|
||||
items[1, 4] = new Items("Millets", 4, 4);
|
||||
items[1, 5] = new Items("Oil Seeds", 4, 5);
|
||||
items[1, 6] = new Items("Paddy", 5, 6);
|
||||
items[1, 7] = new Items("Pulses", 5, 7);
|
||||
items[1, 8] = new Items("Sugarcane", 3, 8);
|
||||
items[1, 9] = new Items("Tobacco", 2, 9);
|
||||
items[1, 10] = new Items("Wheat", 2, 10);
|
||||
}
|
||||
|
||||
public void addItem(Items item, int Type)
|
||||
|
@ -11,7 +11,7 @@ using Microsoft.Xna.Framework.Input;
|
||||
class Inventory
|
||||
{
|
||||
private int Weight = 0;
|
||||
private int maxWeight = 25;
|
||||
private int maxWeight = 350;
|
||||
private Cargo cargo = new Cargo();
|
||||
private Cargo itemStorage = new Cargo();
|
||||
|
||||
@ -101,6 +101,7 @@ class Inventory
|
||||
|
||||
public void removeItem(int Index, int Type)
|
||||
{
|
||||
Weight = Weight - itemStorage.getItemByIndex(Index, Type).getWeight();
|
||||
cargo.removeItem(Index, Type);
|
||||
}
|
||||
|
||||
@ -109,6 +110,37 @@ class Inventory
|
||||
return itemStorage;
|
||||
}
|
||||
|
||||
public void clearInventory()
|
||||
{
|
||||
for (int i = 0; i <= 6; i++)
|
||||
while (useItem(i, 0)) ;
|
||||
|
||||
for (int i = 0; i <= 10; i++)
|
||||
while (useItem(i, 1)) ;
|
||||
}
|
||||
|
||||
public void fillWithFertilizer()
|
||||
{
|
||||
int i = 0;
|
||||
while (getWeight() < getMaxWeight())
|
||||
{
|
||||
if (i > 6)
|
||||
i = 0;
|
||||
addItem(i, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isMissingFertilizer()
|
||||
{
|
||||
for (int i = 0; i <= 6; i++)
|
||||
{
|
||||
if (!itemExists(i, 0))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void printItems(Input input, SpriteBatch spriteBatch, SpriteFont Bold)
|
||||
{
|
||||
|
||||
|
@ -1,14 +1,19 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
class Tractor
|
||||
{
|
||||
private int Spacing, sizeTile, Speed = 1;
|
||||
private float tractorSpeed = 1;
|
||||
private Vector2 Position, TargetPosition, Size, housePos;
|
||||
private Vector2 Position, TargetPosition, Size, housePos, oldDeltaPosition, DeltaPosition;
|
||||
private Path path = new Path();
|
||||
private SmartTractor smartTractor = new SmartTractor();
|
||||
private HandleRotation handleRotation = new HandleRotation();
|
||||
private int WaitFrame = 30;
|
||||
private int j;
|
||||
|
||||
|
||||
|
||||
public void updateSizing(Input input, int Status, Vector2 newHousePos, DayNightCycle Time)
|
||||
{
|
||||
@ -18,6 +23,7 @@ class Tractor
|
||||
updatePosition(input.getSize(), Status);
|
||||
housePos = newHousePos;
|
||||
smartTractor.UpdateCrops(Speed);
|
||||
|
||||
}
|
||||
|
||||
public void init(Rectangle house, Input input)
|
||||
@ -26,13 +32,14 @@ class Tractor
|
||||
Spacing = input.getSpacing();
|
||||
Position = housePos;
|
||||
TargetPosition = new Vector2(house.X, house.Y);
|
||||
smartTractor.init();
|
||||
smartTractor.init(new Vector2(house.X, house.Y));
|
||||
}
|
||||
|
||||
// Runs when the tractor reaches a tile
|
||||
private void updateDirection(Vector2 Size, Vector2 newPosition)
|
||||
{
|
||||
Vector2 DeltaPosition = TargetPosition - Position;
|
||||
DeltaPosition = TargetPosition - Position;
|
||||
handleRotation.checkTile(Position, sizeTile, Spacing, tractorSpeed, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))));
|
||||
|
||||
if (DeltaPosition.X == 0)
|
||||
{
|
||||
@ -42,30 +49,49 @@ class Tractor
|
||||
}
|
||||
else if (DeltaPosition.Y > 0)
|
||||
{
|
||||
Position = handleRotation.UpdatePosition(0, tractorSpeed, Position);
|
||||
Position = handleRotation.UpdatePosition(0, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))), DeltaPosition, TargetPosition);
|
||||
}
|
||||
else if (DeltaPosition.Y < 0)
|
||||
{
|
||||
Position = handleRotation.UpdatePosition(1, tractorSpeed, Position);
|
||||
Position = handleRotation.UpdatePosition(1, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))), DeltaPosition, TargetPosition);
|
||||
}
|
||||
}
|
||||
else if (DeltaPosition.X > 0)
|
||||
{
|
||||
Position = handleRotation.UpdatePosition(2, tractorSpeed, Position);
|
||||
Position = handleRotation.UpdatePosition(2, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))), DeltaPosition, TargetPosition);
|
||||
}
|
||||
else if (DeltaPosition.X < 0)
|
||||
{
|
||||
Position = handleRotation.UpdatePosition(3, tractorSpeed, Position);
|
||||
Position = handleRotation.UpdatePosition(3, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))), DeltaPosition, TargetPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updatePosition(Vector2 Size, int Status) // updates the position
|
||||
{
|
||||
|
||||
//farm.updateSize(Size, sizeTile, Spacing);
|
||||
for (int i = 0; i < Speed; i++)
|
||||
{
|
||||
|
||||
updateDirection(Size, Position);
|
||||
|
||||
|
||||
/*
|
||||
if (!smartTractor.getWaitTwoFrames())
|
||||
{
|
||||
updateDirection(Size, Position);
|
||||
j = WaitFrame;
|
||||
}
|
||||
else if (j != 0)
|
||||
{
|
||||
j--;
|
||||
}
|
||||
else
|
||||
{
|
||||
smartTractor.setWaitTwoFrames(false);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@ class Astar
|
||||
var adjacentNodes = new List<Nodes>()
|
||||
|
||||
{
|
||||
new Nodes(new Vector2(currentPos.X, currentPos.Y+1), 0),
|
||||
new Nodes(new Vector2(currentPos.X, currentPos.Y - 1), 0),
|
||||
new Nodes(new Vector2(currentPos.X + 1, currentPos.Y), 1),
|
||||
new Nodes(new Vector2(currentPos.X, currentPos.Y - 1), 2),
|
||||
new Nodes(new Vector2(currentPos.X, currentPos.Y + 1), 2),
|
||||
new Nodes(new Vector2(currentPos.X - 1, currentPos.Y), -1),
|
||||
};
|
||||
|
||||
@ -75,9 +75,9 @@ class Astar
|
||||
if (currDir == newDir)
|
||||
return 0;
|
||||
else if (Math.Abs(currDir - newDir) == 1 || Math.Abs(currDir - newDir) == 3)
|
||||
return 20;
|
||||
return 3;
|
||||
else if (Math.Abs(currDir - newDir) == 0 || Math.Abs(currDir - newDir) == 2)
|
||||
return 900;
|
||||
return 9;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -163,4 +163,71 @@ class Astar
|
||||
return path;
|
||||
}
|
||||
|
||||
public bool isReachable(Crops[,] crops, Vector2 targetPos, Vector2 start)
|
||||
{
|
||||
Rotation = 0;
|
||||
int g = 0;
|
||||
int direction = ConvertRotation();
|
||||
Path path = new Path();
|
||||
MinHeap openList = new MinHeap();
|
||||
MinHeap closedList = new MinHeap();
|
||||
Nodes target = new Nodes(targetPos);
|
||||
Nodes startPos = new Nodes(tractorPos, direction);
|
||||
Nodes current = null;
|
||||
|
||||
openList.Insert(startPos);
|
||||
|
||||
while (openList.GetSize() > 0)
|
||||
{
|
||||
current = openList.getMin();
|
||||
closedList.Insert(current);
|
||||
openList.removeMin();
|
||||
direction = current.getDirection();
|
||||
|
||||
if (current.getCords() == target.getCords())
|
||||
break;
|
||||
|
||||
var adjacentNodes = GetAdjacentNodes(current.getCords());
|
||||
foreach (var adjacentNode in adjacentNodes)
|
||||
{
|
||||
if (closedList.Exists(adjacentNode.getCords())) // check if adjacent node is on closed list, if it is, skip it
|
||||
continue;
|
||||
g = current.getG() + crops[(int)adjacentNode.getCords().X, (int)adjacentNode.getCords().Y].getCostOnMovement() + CalculateRotationCost(direction, adjacentNode.getDirection()); // calculate g - cost from start point
|
||||
if (!(openList.Exists(adjacentNode.getCords()))) // if adjacent node is not on open list, add it
|
||||
{
|
||||
adjacentNode.setG(g);
|
||||
adjacentNode.setH(ComputeHScore(adjacentNode.getCords(), target.getCords()));
|
||||
adjacentNode.calculateF();
|
||||
adjacentNode.setParent(current);
|
||||
openList.Insert(adjacentNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g + adjacentNode.getH() < adjacentNode.getF()) // check if adjacent node is a better path than the current one
|
||||
{
|
||||
adjacentNode.setG(g);
|
||||
adjacentNode.calculateF();
|
||||
adjacentNode.setParent(current);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
while (current != null)
|
||||
{
|
||||
path.AddNode(current);
|
||||
current = current.getParent();
|
||||
}
|
||||
|
||||
openList.deleteHeap();
|
||||
closedList.deleteHeap();
|
||||
|
||||
if (path.getByIndex(0).getCords() != targetPos)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -46,4 +46,9 @@ class PriorityQueueC5
|
||||
queue.AddAll(entryList);
|
||||
}
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return queue.Count();
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Game1.Sources
|
||||
{
|
||||
class Queue
|
||||
{
|
||||
private Task[] task;
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -15,8 +15,10 @@ class AI
|
||||
private Vector2 Size;
|
||||
private Vector2 targetPos;
|
||||
private Inventory inventory = new Inventory();
|
||||
private FertilizerHolder fertilizerHolder = new FertilizerHolder();
|
||||
private int Rotation;
|
||||
private Astar astar = new Astar();
|
||||
public bool WaitTwoFrames { get; set; }
|
||||
|
||||
private Random r = new Random();
|
||||
|
||||
@ -44,20 +46,38 @@ class AI
|
||||
inventory.printItems(input, spriteBatch, Bold);
|
||||
}
|
||||
|
||||
|
||||
public Vector2 newTarget()
|
||||
public Path newTarget()
|
||||
{
|
||||
PriorityQueueC5 queue = new PriorityQueueC5();
|
||||
int score = 0;
|
||||
int count = 0;
|
||||
int testsize = 2;
|
||||
Vector2 newTarget;
|
||||
Path newTarget;
|
||||
Nodes nodes;
|
||||
|
||||
if (astar.GetAdjacentNodes(tractorPos).Count == 0)
|
||||
nodes = new Nodes(housePos);
|
||||
else
|
||||
nodes = astar.GetAdjacentNodes(tractorPos)[0];
|
||||
|
||||
if (tractorPos != housePos)
|
||||
if (inventory.getWeight() == inventory.getMaxWeight() || inventory.isMissingFertilizer())
|
||||
{
|
||||
astar.update(farm.getCrops(), Size, tractorPos, housePos, housePos, Rotation);
|
||||
return astar.FindPath(true);
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
for (int x = 0; x < Size.X; x++)
|
||||
for (int y = 0; y < Size.Y; y++)
|
||||
{
|
||||
if (farm.getCrop(x, y).getStatus() >= 2 && tractorPos != new Vector2(x, y))
|
||||
{
|
||||
if (farm.getCrop(x, y).getStatus() != 2 && (farm.getCrop(x, y).getProductionRate() > 0.99f || !farm.getCrop(x, y).belowCapacity()))
|
||||
{
|
||||
//skip growing fields with high production rate
|
||||
}
|
||||
else
|
||||
{
|
||||
score = calculateSoilScore(x, y);
|
||||
queue.AddToQueue(x, y, score);
|
||||
@ -65,32 +85,45 @@ class AI
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0)
|
||||
}
|
||||
break;
|
||||
else if (tractorPos != housePos)
|
||||
return newTarget = GetMaxFNode(testsize, queue);
|
||||
}
|
||||
|
||||
/*
|
||||
else if (tractorPos == housePos)
|
||||
if (queue.getCount() == 0)
|
||||
{
|
||||
List<Nodes> temp = astar.GetAdjacentNodes(tractorPos);
|
||||
return temp[0].getCords();
|
||||
astar.update(farm.getCrops(), Size, tractorPos, housePos, nodes.getCords(), Rotation);
|
||||
return newTarget = astar.FindPath(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
newTarget = GetMinFNode(Math.Min(testsize, count), queue);
|
||||
|
||||
newTarget = GetMinFNode(Math.Min(testsize, queue.getCount()), queue);
|
||||
queue = null;
|
||||
|
||||
return newTarget;
|
||||
}
|
||||
|
||||
public Farm changeCropStatus()
|
||||
{
|
||||
if (farm.getCrop((int)tractorPos.X, (int)tractorPos.Y).getCropTimer() == 1)
|
||||
int x = (int)tractorPos.X;
|
||||
int y = (int)tractorPos.Y;
|
||||
Fertilizer fertilizer = new Fertilizer();
|
||||
fertilizerHolder.init();
|
||||
WaitTwoFrames = false;
|
||||
if (farm.getCrop(x, y).getStatus() >= 2)
|
||||
{
|
||||
fertilizer = fertilizerHolder.GetFertilizer(Engine.PredictFertilizer(farm.getCrop(x, y), farm.getPresetCropTypes(farm.getCrop(x, y).getCropType())));
|
||||
while (!(farm.getCrop(x, y).isSaturated(-1)) && farm.getCrop(x, y).belowCapacity() && inventory.useItem(fertilizerHolder.GetFertilizerID(fertilizer.Name), 0))
|
||||
{
|
||||
farm.getCrop(x, y).Fertilize(fertilizer);
|
||||
fertilizer = fertilizerHolder.GetFertilizer(Engine.PredictFertilizer(farm.getCrop(x, y), farm.getPresetCropTypes(farm.getCrop(x, y).getCropType())));
|
||||
WaitTwoFrames = true;
|
||||
}
|
||||
}
|
||||
if (farm.getCrop(x, y).getCropTimer() == 1)
|
||||
{
|
||||
farm.setCropStatus(tractorPos.X, tractorPos.Y);
|
||||
if (farm.getCrop((int)tractorPos.X, (int)tractorPos.Y).getStatus() == 2)
|
||||
if (farm.getCrop(x, y).getStatus() == 2)
|
||||
{
|
||||
inventory.addItem(farm.getCrop((int)tractorPos.X, (int)tractorPos.Y).getCropType() - 1, 1);
|
||||
inventory.addItem(farm.getCrop(x, y).getCropType() - 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@ -104,33 +137,38 @@ class AI
|
||||
|
||||
private int calculateSoilScore(int x, int y)
|
||||
{
|
||||
int score = 0;
|
||||
int statusScore = 0;
|
||||
int timerScore = 0;
|
||||
int score = 1;
|
||||
int statusScore = 1;
|
||||
int timerScore = 1;
|
||||
int saturationScore = 1;
|
||||
int productionRateScore = 1;
|
||||
int aproxDistance = (int)(Math.Abs(x - tractorPos.X) + Math.Abs(y - tractorPos.Y));
|
||||
CropTypesHolder holder = new CropTypesHolder();
|
||||
holder.init();
|
||||
|
||||
Crops crop = farm.getCrop(x, y);
|
||||
SoilProperties soilP = crop.getSoilProperties();
|
||||
int cropType = crop.getCropType();
|
||||
CropTypes avgHold = holder.getPresetCropTypes(cropType);
|
||||
|
||||
if (crop.getStatus() == 2)
|
||||
statusScore = 25;
|
||||
else if (crop.getStatus() == 3)
|
||||
statusScore = -100;
|
||||
else
|
||||
statusScore = 1;
|
||||
|
||||
if (crop.getCropTimer() == 1)
|
||||
timerScore = 999;
|
||||
timerScore = 100;
|
||||
|
||||
productionRateScore = (int)(crop.getProductionRate() * 25);
|
||||
score = (int)(crop.getProductionRate() * -50);
|
||||
|
||||
if (crop.getStatus() == 2)
|
||||
{
|
||||
statusScore = 50;
|
||||
productionRateScore = 0;
|
||||
}
|
||||
else if (crop.getStatus() == 3)
|
||||
statusScore = -100;
|
||||
|
||||
if (!crop.isSaturated(2))
|
||||
saturationScore = 5;
|
||||
else
|
||||
statusScore = 0;
|
||||
{
|
||||
saturationScore = -100;
|
||||
}
|
||||
|
||||
score = (int)(crop.getProductionRate(avgHold) * 10);
|
||||
|
||||
return score + (-aproxDistance * 5) + statusScore + timerScore;
|
||||
return score + (-aproxDistance * 5) + statusScore + timerScore + saturationScore;
|
||||
}
|
||||
|
||||
private float norm(float min, float max, float val)
|
||||
@ -138,12 +176,13 @@ class AI
|
||||
return ((val - min) / (max - min));
|
||||
}
|
||||
|
||||
public Vector2 GetMinFNode(int testSize, PriorityQueueC5 queue)
|
||||
public Path GetMinFNode(int testSize, PriorityQueueC5 queue)
|
||||
{
|
||||
int index = 0;
|
||||
int min = 9999;
|
||||
Path path = new Path();
|
||||
List<PQEntry> entryList = new List<PQEntry>();
|
||||
Path[] pathList = new Path[testSize];
|
||||
for (int i = 0; i < testSize; i++)
|
||||
{
|
||||
entryList.Add(queue.DeleteMax());
|
||||
@ -152,7 +191,9 @@ class AI
|
||||
for (int i = 0; i < testSize; i++)
|
||||
{
|
||||
Nodes temp = new Nodes(entryList[i].Coordinates);
|
||||
astar.update(farm.getCrops(), Size, tractorPos, housePos, temp.getCords(), Rotation);
|
||||
path = astar.FindPath(false);
|
||||
pathList[i] = path;
|
||||
Nodes tempF = new Nodes(path.getByIndex(0));
|
||||
if (min > tempF.getF())
|
||||
{
|
||||
@ -160,21 +201,17 @@ class AI
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
PQEntry minEntry = entryList[index];
|
||||
entryList.RemoveAt(index);
|
||||
|
||||
//add the non-minimum entries back to the queue.
|
||||
queue.AddAll(entryList);
|
||||
|
||||
return minEntry.Coordinates;
|
||||
return pathList[index].FlipArray();
|
||||
}
|
||||
|
||||
public Vector2 GetMaxFNode(int testSize, PriorityQueueC5 queue)
|
||||
public Path GetMaxFNode(int testSize, PriorityQueueC5 queue)
|
||||
{
|
||||
int index = 0;
|
||||
int max = -9999;
|
||||
Path path = new Path();
|
||||
List<PQEntry> entryList = new List<PQEntry>();
|
||||
Path[] pathList = new Path[testSize];
|
||||
for (int i = 0; i < testSize; i++)
|
||||
{
|
||||
entryList.Add(queue.DeleteMax());
|
||||
@ -183,7 +220,9 @@ class AI
|
||||
for (int i = 0; i < testSize; i++)
|
||||
{
|
||||
Nodes temp = new Nodes(entryList[i].Coordinates);
|
||||
astar.update(farm.getCrops(), Size, tractorPos, housePos, temp.getCords(), Rotation);
|
||||
path = astar.FindPath(false);
|
||||
pathList[i] = path;
|
||||
Nodes tempF = new Nodes(path.getByIndex(0));
|
||||
if (max < tempF.getF())
|
||||
{
|
||||
@ -191,13 +230,16 @@ class AI
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
PQEntry minEntry = entryList[index];
|
||||
entryList.RemoveAt(index);
|
||||
|
||||
//add the non-minimum entries back to the queue.
|
||||
queue.AddAll(entryList);
|
||||
return pathList[index].FlipArray();
|
||||
}
|
||||
|
||||
|
||||
public void reloadCargo()
|
||||
{
|
||||
inventory.clearInventory();
|
||||
inventory.fillWithFertilizer();
|
||||
|
||||
return minEntry.Coordinates;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,10 +20,13 @@ class SmartTractor
|
||||
farm.UpdatePreferedCrops(Size);
|
||||
farm = ai.changeCropStatus();
|
||||
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Rotation);
|
||||
getTargetPosition(ai.newTarget());
|
||||
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
|
||||
//getTargetPosition(ai.newTarget());
|
||||
//astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
|
||||
if (tractorPos == housePos)
|
||||
ai.reloadCargo();
|
||||
|
||||
return astar.FindPath(true);
|
||||
return ai.newTarget();
|
||||
//return astar.FindPath(true);
|
||||
}
|
||||
|
||||
|
||||
@ -43,9 +46,10 @@ class SmartTractor
|
||||
|
||||
}
|
||||
|
||||
public void init()
|
||||
public void init(Vector2 nHousePos)
|
||||
{
|
||||
ai.init();
|
||||
housePos = nHousePos;
|
||||
farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize), housePos / (tileSize + Spacing));
|
||||
}
|
||||
|
||||
@ -81,4 +85,14 @@ class SmartTractor
|
||||
{
|
||||
return ai.getInventory();
|
||||
}
|
||||
|
||||
public bool getWaitTwoFrames()
|
||||
{
|
||||
return ai.WaitTwoFrames;
|
||||
}
|
||||
|
||||
public void setWaitTwoFrames(bool input)
|
||||
{
|
||||
ai.WaitTwoFrames = input;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Game1.Sources
|
||||
{
|
||||
class Task
|
||||
{
|
||||
private Vector2 Position;
|
||||
private int Objective;
|
||||
private float timer;
|
||||
|
||||
public void setTimer(float newTimer)
|
||||
{
|
||||
timer = newTimer;
|
||||
}
|
||||
public void updateTimer()
|
||||
{
|
||||
timer = timer - 1 / 60;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
|
||||
|
||||
class Tractor
|
||||
{
|
||||
static private Vector2 Position;
|
||||
private Vector2 TargetPosition;
|
||||
private Vector2 Direction;
|
||||
private int Spacing, sizeTile;
|
||||
private int Speed = 1;
|
||||
private Vector2 Size;
|
||||
private Random r = new Random();
|
||||
private Farm farm = new Farm();
|
||||
private Vector2 housePos;
|
||||
private String currentTask;
|
||||
private SmartTractor smartTractor = new SmartTractor();
|
||||
private int Score;
|
||||
private int previousTask;
|
||||
|
||||
public void updateSizing(Input input, int Status, Vector2 newHousePos)
|
||||
{
|
||||
Spacing = input.getSpacing();
|
||||
sizeTile = input.getTileSize();
|
||||
Size = input.getSize();
|
||||
updatePosition(input.getSize(), Status);
|
||||
housePos = newHousePos;
|
||||
}
|
||||
|
||||
|
||||
public void init(Rectangle house)
|
||||
{
|
||||
sizeTile = 56;
|
||||
Spacing = 1;
|
||||
farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / sizeTile) - 125 / sizeTile));
|
||||
Position = housePos;
|
||||
}
|
||||
|
||||
private int updateDirection(Vector2 Size, Vector2 newPosition) /// Runs when the tractor reaches a tile
|
||||
{
|
||||
Vector2 DeltaPosition = TargetPosition - Position;
|
||||
if (DeltaPosition.X == 0)
|
||||
{
|
||||
if (DeltaPosition.Y == 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (housePos != Position)
|
||||
{
|
||||
int x = (int)Position.X / (sizeTile + Spacing);
|
||||
int y = (int)Position.Y / (sizeTile + Spacing);
|
||||
currentTask = currentTaskDecider(farm.getCrop(x, y).Status, 0);
|
||||
farm.setCropStatus(x, y, Spacing);
|
||||
setTargetPosition(housePos); //Returns to the farm
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setTargetPosition(smartTractor.returnChoice()); //Sets a random Target
|
||||
int xTarget = (int)TargetPosition.X / (sizeTile + Spacing);
|
||||
int yTarget = (int)TargetPosition.Y / (sizeTile + Spacing);
|
||||
currentTask = currentTaskDecider(farm.getCrop(xTarget, yTarget).Status, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (DeltaPosition.Y > 0)
|
||||
{
|
||||
Direction = new Vector2(0, 1);
|
||||
return 0;
|
||||
}
|
||||
else if (DeltaPosition.Y < 0)
|
||||
{
|
||||
Direction = new Vector2(0, -1);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (DeltaPosition.X > 0)
|
||||
{
|
||||
Direction = new Vector2(1, 0);
|
||||
return 0;
|
||||
}
|
||||
else if (DeltaPosition.X < 0)
|
||||
{
|
||||
Direction = new Vector2(-1, 0);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public void updatePosition(Vector2 Size, int Status) /// updates the position
|
||||
{
|
||||
|
||||
farm.updateSize(Size, sizeTile, Spacing);
|
||||
for (int i = 0; i < Speed; i++) //Where all the choices the tractor does comes from
|
||||
{
|
||||
smartTractor.updateMap(Position, housePos, farm.getCrops(), Size, sizeTile, Spacing, Score);
|
||||
Position = Position + Direction;
|
||||
updateDirection(Size, Position);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Vector2 getPos()
|
||||
{
|
||||
return Position;
|
||||
}
|
||||
|
||||
public void increaseSpeed()
|
||||
{
|
||||
Speed++;
|
||||
}
|
||||
|
||||
public void decreaseSpeed()
|
||||
{
|
||||
if (Speed > 0)
|
||||
{
|
||||
Speed--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setTargetPosition(Vector2 newPosition) /// sets the TargetPosition once it reaches its destination
|
||||
{
|
||||
TargetPosition = newPosition;
|
||||
}
|
||||
public void setSpeed(int newSpeed)
|
||||
{
|
||||
Speed = newSpeed;
|
||||
}
|
||||
|
||||
public int getSpeed()
|
||||
{
|
||||
return Speed;
|
||||
}
|
||||
|
||||
public void setPos(Vector2 newPos)
|
||||
{
|
||||
Position = newPos;
|
||||
}
|
||||
|
||||
public Farm getFarm()
|
||||
{
|
||||
return farm;
|
||||
}
|
||||
|
||||
public Vector2 getTargetPosition()
|
||||
{
|
||||
return TargetPosition;
|
||||
}
|
||||
|
||||
public String getCurrentTask()
|
||||
{
|
||||
return currentTask;
|
||||
}
|
||||
|
||||
public int getScore()
|
||||
{
|
||||
return Score;
|
||||
}
|
||||
|
||||
private String currentTaskDecider(int Status, int Stage)
|
||||
{
|
||||
previousTask = Status;
|
||||
if (previousTask == 3 && Stage != 1)
|
||||
{
|
||||
Score++;
|
||||
}
|
||||
if (Stage == 0)
|
||||
{
|
||||
if (Status == 0)
|
||||
{
|
||||
return "Returning with nothing after going out for a stroll";
|
||||
}
|
||||
else if (Status == 1)
|
||||
{
|
||||
return "Returning with nothing after planting seeds";
|
||||
}
|
||||
else if (Status == 2)
|
||||
{
|
||||
return "Returning with nothing after adding fertilizer";
|
||||
}
|
||||
else if (Status == 3)
|
||||
{
|
||||
return "Returning with Crops";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Status == 0)
|
||||
{
|
||||
return "Going for a stroll";
|
||||
}
|
||||
else if (Status == 1)
|
||||
{
|
||||
return "Planting seeds";
|
||||
}
|
||||
else if (Status == 2)
|
||||
{
|
||||
return "Adding fertilizer";
|
||||
}
|
||||
else if (Status == 3)
|
||||
{
|
||||
return "Going for Crops";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
class SmartTractor
|
||||
{
|
||||
private Crops[,] crops;
|
||||
private Vector2 housePos;
|
||||
private Vector2 tractorPos;
|
||||
private Vector2 Size;
|
||||
private int tileSize;
|
||||
private int Score;
|
||||
private int Spacing;
|
||||
private Random r = new Random();
|
||||
|
||||
|
||||
|
||||
public Vector2 returnChoice()
|
||||
{
|
||||
return new Vector2(r.Next(0, (int)Size.X), r.Next(0, (int)Size.Y)) * (tileSize + Spacing);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void updateMap(Vector2 newTractorPos, Vector2 newHousePos, Crops[,] newCropsStatus, Vector2 newSize, int newTileSize, int newSpacing, int newScore)
|
||||
{
|
||||
crops = newCropsStatus;
|
||||
housePos = newHousePos;
|
||||
tractorPos = newTractorPos;
|
||||
Size = newSize;
|
||||
tileSize = newTileSize;
|
||||
Spacing = newSpacing;
|
||||
Score = newScore;
|
||||
}
|
||||
}
|
@ -7,14 +7,14 @@
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.5.0" newVersion="1.2.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.5.0" newVersion="1.2.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Dataflow" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.6.5.0" newVersion="4.6.5.0" />
|
||||
|
210
MigrationBackup/7a07b01e/Game1/Game1.csproj
Normal file
210
MigrationBackup/7a07b01e/Game1/Game1.csproj
Normal file
@ -0,0 +1,210 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\LightGBM.2.3.1\build\LightGBM.props" Condition="Exists('..\packages\LightGBM.2.3.1\build\LightGBM.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.FastTree.1.4.0\build\netstandard2.0\Microsoft.ML.FastTree.props" Condition="Exists('..\packages\Microsoft.ML.FastTree.1.4.0\build\netstandard2.0\Microsoft.ML.FastTree.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.props" Condition="Exists('..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.props')" />
|
||||
<Import Project="..\packages\Microsoft.ML.CpuMath.1.4.0\build\netstandard2.0\Microsoft.ML.CpuMath.props" Condition="Exists('..\packages\Microsoft.ML.CpuMath.1.4.0\build\netstandard2.0\Microsoft.ML.CpuMath.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{650E4519-2DEF-496F-AC3B-3C794DC7CF0D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Game1</RootNamespace>
|
||||
<AssemblyName>Game1</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MonoGamePlatform>Windows</MonoGamePlatform>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Sources\ML\MLModel.cs" />
|
||||
<Compile Include="Sources\ML\ModelOutput.cs" />
|
||||
<Compile Include="Sources\ML\ModelInput.cs" />
|
||||
<Compile Include="Sources\Objects\House.cs" />
|
||||
<Compile Include="Sources\Crops\Crops.cs" />
|
||||
<Compile Include="Sources\Crops\Farm.cs" />
|
||||
<Compile Include="Sources\Controlls\Input.cs" />
|
||||
<Compile Include="Sources\Objects\Inventory.cs" />
|
||||
<Compile Include="Sources\Objects\tractorPositionCorrector.cs" />
|
||||
<Compile Include="Sources\Pathing\A-Star\Astar.cs" />
|
||||
<Compile Include="Sources\Pathing\A-Star\PathSaver\MinHeap.cs" />
|
||||
<Compile Include="Sources\Pathing\A-Star\PathSaver\Nodes.cs" />
|
||||
<Compile Include="Sources\Pathing\A-Star\PathSaver\Path.cs" />
|
||||
<Compile Include="Sources\Pathing\A-Star\PathSaver\PriorityQueue.cs" />
|
||||
<Compile Include="Sources\Controlls\Controller.cs" />
|
||||
<Compile Include="Sources\Smart\AI.cs" />
|
||||
<Compile Include="Sources\Smart\ScoreSystem.cs" />
|
||||
<Compile Include="Sources\Smart\SmartTractor.cs" />
|
||||
<Compile Include="Sources\Objects\Tractor.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.1.4.0\lib\netstandard2.0\Microsoft.ML.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.CpuMath, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.CpuMath.1.4.0\lib\netstandard2.0\Microsoft.ML.CpuMath.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.1.4.0\lib\netstandard2.0\Microsoft.ML.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.DataView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.DataView.1.4.0\lib\netstandard2.0\Microsoft.ML.DataView.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.FastTree, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.FastTree.1.4.0\lib\netstandard2.0\Microsoft.ML.FastTree.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.KMeansClustering, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.1.4.0\lib\netstandard2.0\Microsoft.ML.KMeansClustering.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.LightGbm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.LightGbm.1.4.0\lib\netstandard2.0\Microsoft.ML.LightGbm.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.PCA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.1.4.0\lib\netstandard2.0\Microsoft.ML.PCA.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.StandardTrainers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.1.4.0\lib\netstandard2.0\Microsoft.ML.StandardTrainers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ML.Transforms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ML.1.4.0\lib\netstandard2.0\Microsoft.ML.Transforms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MonoGame.Framework">
|
||||
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.CodeDom, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.CodeDom.4.7.0\lib\net461\System.CodeDom.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.7.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Dataflow, Version=4.6.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Dataflow.4.11.0\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Crop.png" />
|
||||
<Content Include="Content\house.png" />
|
||||
<Content Include="Content\ProgressionBarStatus.png" />
|
||||
<Content Include="Content\ProgressionBar.png" />
|
||||
<Content Include="Content\Markers.png" />
|
||||
<Content Include="Content\Mountain.png" />
|
||||
<Content Include="Content\Planted.png" />
|
||||
<Content Include="Content\Tile.png" />
|
||||
<Content Include="Content\tileunplantable.png" />
|
||||
<Content Include="Content\Tractor.png" />
|
||||
<Content Include="Icon.ico" />
|
||||
<None Include="Resources\TextFile1.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
<None Include="app.config" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Sources\ML\Data\Fertilizer Prediction.csv" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.CpuMath.1.4.0\build\netstandard2.0\Microsoft.ML.CpuMath.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.CpuMath.1.4.0\build\netstandard2.0\Microsoft.ML.CpuMath.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.FastTree.1.4.0\build\netstandard2.0\Microsoft.ML.FastTree.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.FastTree.1.4.0\build\netstandard2.0\Microsoft.ML.FastTree.props'))" />
|
||||
<Error Condition="!Exists('..\packages\LightGBM.2.3.1\build\LightGBM.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LightGBM.2.3.1\build\LightGBM.props'))" />
|
||||
<Error Condition="!Exists('..\packages\LightGBM.2.3.1\build\LightGBM.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LightGBM.2.3.1\build\LightGBM.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.targets" Condition="Exists('..\packages\Microsoft.ML.1.4.0\build\netstandard2.0\Microsoft.ML.targets')" />
|
||||
<Import Project="..\packages\LightGBM.2.3.1\build\LightGBM.targets" Condition="Exists('..\packages\LightGBM.2.3.1\build\LightGBM.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
174
MigrationBackup/7a07b01e/Game1/NuGetUpgradeLog.html
Normal file
174
MigrationBackup/7a07b01e/Game1/NuGetUpgradeLog.html
Normal file
@ -0,0 +1,174 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- saved from url=(0014)about:internet -->
|
||||
|
||||
<html xmlns:msxsl="urn:schemas-microsoft-com:xslt"><head><meta content="en-us" http-equiv="Content-Language" /><meta content="text/html; charset=utf-16" http-equiv="Content-Type" /><title _locID="NuGetUpgradeReportTitle">
|
||||
NuGetMigrationLog
|
||||
</title><style>
|
||||
|
||||
/* Body style, for the entire document */
|
||||
body
|
||||
{
|
||||
background: #F3F3F4;
|
||||
color: #1E1E1F;
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-size: 12pt;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Header1 style, used for the main title */
|
||||
h1
|
||||
{
|
||||
padding: 10px 0px 10px 10px;
|
||||
font-size: 21pt;
|
||||
background-color: #E2E2E2;
|
||||
border-bottom: 1px #C1C1C2 solid;
|
||||
color: #201F20;
|
||||
margin: 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* Header2 style, used for "Overview" and other sections */
|
||||
h2
|
||||
{
|
||||
font-size: 18pt;
|
||||
font-weight: normal;
|
||||
padding: 15px 0 5px 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Header3 style, used for sub-sections, such as project name */
|
||||
h3
|
||||
{
|
||||
font-weight: normal;
|
||||
font-size: 15pt;
|
||||
margin: 0;
|
||||
padding: 15px 0 5px 0;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.info-text
|
||||
{
|
||||
margin: 0px 0 0.75em 0;
|
||||
}
|
||||
|
||||
/* Color all hyperlinks one color */
|
||||
a
|
||||
{
|
||||
color: #1382CE;
|
||||
}
|
||||
|
||||
/* Table styles */
|
||||
table
|
||||
{
|
||||
border-spacing: 0 0;
|
||||
border-collapse: collapse;
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
table th
|
||||
{
|
||||
background: #E7E7E8;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
font-weight: normal;
|
||||
padding: 3px 6px 3px 6px;
|
||||
}
|
||||
|
||||
table td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 3px 6px 5px 5px;
|
||||
margin: 0px;
|
||||
border: 1px solid #E7E7E8;
|
||||
background: #F7F7F8;
|
||||
}
|
||||
|
||||
/* Local link is a style for hyperlinks that link to file:/// content, there are lots so color them as 'normal' text until the user mouse overs */
|
||||
.localLink
|
||||
{
|
||||
color: #1E1E1F;
|
||||
background: #EEEEED;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.localLink:hover
|
||||
{
|
||||
color: #1382CE;
|
||||
background: #FFFF99;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.issueCell
|
||||
{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.packageIssue
|
||||
{
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
/* Padding around the content after the h1 */
|
||||
#content
|
||||
{
|
||||
padding: 0px 20px 20px 20px;
|
||||
}
|
||||
|
||||
.issues table
|
||||
{
|
||||
width: 97%;
|
||||
}
|
||||
|
||||
/* All Icons */
|
||||
.IconSuccessEncoded, .IconInfoEncoded, .IconWarningEncoded, .IconErrorEncoded
|
||||
{
|
||||
min-width:18px;
|
||||
min-height:18px;
|
||||
background-repeat:no-repeat;
|
||||
background-position:center;
|
||||
}
|
||||
|
||||
.IconSuccessEncoded
|
||||
{
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABcElEQVR4Xq2TsUsCURzHv15g8ZJcBWlyiYYgCIWcb9DFRRwMW5TA2c0/QEFwFkxxUQdxVlBwCYWOi6IhWgQhBLHJUCkhLr/BW8S7gvrAg+N+v8/v+x68Z8MGy+XSCyABQAXgBgHGALoASkIIDWSLeLBetdHryMjd5IxQPWT4rn1c/P7+xxp72Cs9m5SZ0Bq2vPnbPFafK2zDvmNHypdC0BPkLlQhxJsCAhQoZwdZU5mwxh720qGo8MzTxTTKZDPCx2HoVzp6lz0Q9tKhyx0kGs8Ny+TkWRKk8lCROwEduhyg9l/6lunOPSfmH3NUH6uQ0KHLAe7JYvJjevm+DAMGJHToKtigE+vwvIidxLamb8IBY9e+C5LiXREkfho3TSd06HJA13/oh6T51MTsfQbHrsMynQ5dDihFjiK8JJAU9AKIWTp76dCVN7HWHrajmUEGvyF9nkbAE6gLIS7kTUyuf2gscLoJrElZo/Mvj+nPz/kLTmfnEwP3tB0AAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
.IconInfoEncoded
|
||||
{
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHElEQVR4Xs2TsUoDQRRF7wwoziokjZUKadInhdhukR9YP8DMX1hYW+QvdsXa/QHBbcXC7W0CamWTQnclFutceIQJwwaWNLlwm5k5d94M76mmaeCrrmsLYOocY12FcxZFUeozCqKqqgYA8uevv1H6VuPxcwlfk5N92KHBxfFeCSAxxswlYAW/Xr989x/mv9gkhtyMDhcAxgzRsp7flj8B/HF1RsMXq+NZMkopaHe7lbKxQUEIGbKsYNoGn969060hZBkQex/W8oRQwsQaW2o3Ago2SVcJUzAgY3N0lTCZZm+zPS8HB51gMmS1DEYyOz9acKO1D8JWTlafKIMxdhvlfdyT94Vv5h7P8Ky7nQzACmhvKq3zk3PjW9asz9D/1oigecsioooAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
.IconWarningEncoded
|
||||
{
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAx0lEQVR4XpWSMQ7CMAxFf4xAyBMLCxMrO8dhaBcuwdCJS3RJBw7SA/QGTCxdWJgiQYWKXJWKIXHIlyw5lqr34tQgEOdcBsCOx5yZK3hCCKdYXneQkh4pEfqzLfu+wVDSyyzFoJjfz9NB+pAF+eizx2Vruts0k15mPgvS6GYvpVtQhB61IB/dk6AF6fS4Ben0uIX5odtFe8Q/eW1KvFeH4e8khT6+gm5B+t3juyDt7n0jpe+CANTd+oTUjN/U3yVaABnSUjFz/gFq44JaVSCXeQAAAABJRU5ErkJggg==);
|
||||
}
|
||||
|
||||
.IconErrorEncoded
|
||||
{
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABQElEQVR4XqWTvUoEQRCE6wYPZUA80AfwAQz23uCMjA7MDRQEIzPBVEyNTQUFIw00vcQTTMzuAh/AxEQQT8HF/3G/oGGnEUGuoNnd6qoZuqltyKEsyzVJq5I6rnUp6SjGeGhESikzzlc1eL7opfuVbrqbU1Zw9NCgtQMaZpY0eNnaaL2fHusvTK5vKu7sjSS1Y4y3QUA6K3e3Mau5UFDyMP7tYF9o8cAHZv68vipoIJg971PZIZ5HiwdvYGGvFVFHmGmZ2MxwmQYPXubPl9Up0tfoMQGetXd6mRbvhBw+boZ6WF7Mbv1+GsHRk0fQmPAH1GfmZirbCfDJ61tw3Px8/8pZsPAG4jlVhcPgZ7adwNWBB68lkRQWFiTgFlbnLY3DGGM7izIJIyT/jjIvEJw6fdJTc6krDzh6aMwMP9bvDH4ADSsa9uSWVJkAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
</style></head><body><h1>
|
||||
NuGet Migration Report - Game1</h1><div id="content"><h2 _locID="OverviewTitle">Overview</h2><div class="info-text">Migration to PackageReference was completed successfully. Please build and run your solution to verify that all packages are available.</div><div class="info-text">
|
||||
If you run into any problems, have feedback, questions, or concerns, please
|
||||
<a href="https://github.com/NuGet/Home/issues/">file an issue on the NuGet GitHub repository.</a></div><div class="info-text">
|
||||
Changed files and this report have been backed up here:
|
||||
<a href="C:\Users\Oskar\source\repos\PotatoPlanFinal\MigrationBackup\7a07b01e\Game1">C:\Users\Oskar\source\repos\PotatoPlanFinal\MigrationBackup\7a07b01e\Game1</a></div><div class="info-text"><a href="https://aka.ms/nuget-pc2pr-migrator-rollback">Help me rollback to packages.config</a></div><h2 _locID="PackagesTitle">Packages processed</h2><h3 _locID="IncludePackagesTitle">Top-level dependencies:</h3><div class="issues"><table><tr><th class="issueCell">Package Id</th><th>Version</th></tr><tr><td class="issueCell"><span>LightGBM</span></td><td><span>
|
||||
v2.3.1</span></td></tr><tr><td class="issueCell"><span>Microsoft.ML</span></td><td><span>
|
||||
v1.4.0</span></td></tr><tr><td class="issueCell"><span>Microsoft.ML.CpuMath</span></td><td><span>
|
||||
v1.4.0</span></td></tr><tr><td class="issueCell"><span>Microsoft.ML.FastTree</span></td><td><span>
|
||||
v1.4.0</span></td></tr><tr><td class="issueCell"><span>Microsoft.ML.LightGbm</span></td><td><span>
|
||||
v1.4.0</span></td></tr><tr><td class="issueCell"><span>Newtonsoft.Json</span></td><td><span>
|
||||
v12.0.3</span></td></tr><tr><td class="issueCell"><span>System.CodeDom</span></td><td><span>
|
||||
v4.7.0</span></td></tr><tr><td class="issueCell"><span>System.Collections.Immutable</span></td><td><span>
|
||||
v1.7.0</span></td></tr><tr><td class="issueCell"><span>System.Memory</span></td><td><span>
|
||||
v4.5.4</span></td></tr><tr><td class="issueCell"><span>System.Reflection.Emit.Lightweight</span></td><td><span>
|
||||
v4.7.0</span></td></tr><tr><td class="issueCell"><span>System.Runtime.CompilerServices.Unsafe</span></td><td><span>
|
||||
v4.7.1</span></td></tr><tr><td class="issueCell"><span>System.Threading.Tasks.Dataflow</span></td><td><span>
|
||||
v4.11.0</span></td></tr></table></div><p /><h3 _locID="IncludePackagesTitle">Transitive dependencies:</h3><div class="issues"><table><tr><th class="issueCell">Package Id</th><th>Version</th></tr><tr><td class="issueCell"><span>Microsoft.ML.DataView</span></td><td><span>
|
||||
v1.4.0</span></td></tr><tr><td class="issueCell"><span>System.Buffers</span></td><td><span>
|
||||
v4.5.1</span></td></tr><tr><td class="issueCell"><span>System.Numerics.Vectors</span></td><td><span>
|
||||
v4.5.0</span></td></tr></table></div><h2 _locID="IssuesTitle">Package compatibility issues</h2><div class="issues"><table><tr><th /><th class="issueCell" _locID="DescriptionTableHeader">Description</th></tr><tr><td class="IconInfoEncoded" /><td class="issueCell">
|
||||
No issues were found.
|
||||
</td></tr></table></div></div></body></html>
|
18
MigrationBackup/7a07b01e/Game1/packages.config
Normal file
18
MigrationBackup/7a07b01e/Game1/packages.config
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="LightGBM" version="2.3.1" targetFramework="net461" />
|
||||
<package id="Microsoft.ML" version="1.4.0" targetFramework="net461" />
|
||||
<package id="Microsoft.ML.CpuMath" version="1.4.0" targetFramework="net461" />
|
||||
<package id="Microsoft.ML.DataView" version="1.4.0" targetFramework="net461" />
|
||||
<package id="Microsoft.ML.FastTree" version="1.4.0" targetFramework="net461" />
|
||||
<package id="Microsoft.ML.LightGbm" version="1.4.0" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net461" />
|
||||
<package id="System.CodeDom" version="4.7.0" targetFramework="net461" />
|
||||
<package id="System.Collections.Immutable" version="1.7.0" targetFramework="net461" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net461" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
|
||||
<package id="System.Reflection.Emit.Lightweight" version="4.7.0" targetFramework="net461" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
|
||||
<package id="System.Threading.Tasks.Dataflow" version="4.11.0" targetFramework="net461" />
|
||||
</packages>
|
120
Oskar_Nastaly_ML_Report.md
Normal file
120
Oskar_Nastaly_ML_Report.md
Normal file
@ -0,0 +1,120 @@
|
||||
# Machine Learning implementation report
|
||||
|
||||
|
||||
|
||||
## Introduction
|
||||
|
||||
Purpose of my ML implementation is for the agent (tractor) to decide what fertilizer it should use.
|
||||
It's decision is mostly based on nutrients in soil, but also on few other properties.
|
||||
Dataset is very small, it contains only 100 entries.
|
||||
There are 7 types of fertilizers, each of them adding a specific amount of nutrients to the soil.
|
||||
Example:
|
||||
|
||||
FertilizerType[6] = new Fertilizer
|
||||
{
|
||||
ID = 5,
|
||||
Name = "DAP",
|
||||
Nitrogen = 14.52f / 5,
|
||||
Phosphorus = 1.77f / 5,
|
||||
Potassium = 9.5f / 5
|
||||
};
|
||||
|
||||
Unfortunately values of nutrients are not based on real values.
|
||||
That is because even though dataset intention (by it's creator) was to be used to classify fertilizers, it looks like instead it says what fertilizer WAS used and what will be the results of using that fertilizer on some field.
|
||||
E.g: Urea has 46% of Nitrogen in it and nothing else. In dataset it was classified as best fertilizer to be used on fields with already really high Nitrogen levels. That would lead to oversaturation with Nitrogen and lack of other nutrients.
|
||||
So i did some calculations and Urea now looks like this:
|
||||
|
||||
FertilizerType[7] = new Fertilizer
|
||||
{
|
||||
ID = 6,
|
||||
Name = "Urea",
|
||||
Nitrogen = 1.81f / 5,
|
||||
Phosphorus = 21.0f / 5,
|
||||
Potassium = 9.5f / 5
|
||||
};
|
||||
// an "inversed" and little modified counterpart of real-world version of this fertilizer.
|
||||
|
||||
|
||||
## Implementation
|
||||
|
||||
I used Gradient Boosting Decision Tree Algorithm for this task due to many features it has.
|
||||
|
||||
First a csv file is loaded:
|
||||
|
||||
IDataView trainingDataView = mlContext.Data.LoadFromTextFile<ModelInput>(
|
||||
path: path,
|
||||
hasHeader: true,
|
||||
separatorChar: ',',
|
||||
allowQuoting: true,
|
||||
allowSparse: false);
|
||||
|
||||
Then it is passed to next function which will train, evaluate and build a model.
|
||||
Also trainer parameters will be fine-tuned here to prevent overfitting as much as possible by:
|
||||
- limiting number of leaves,
|
||||
- limiting maximum tree depth,
|
||||
- limiting the amount of bins per feature,
|
||||
while maintaining high accuracy by:
|
||||
- low learning rate combine with
|
||||
- high number of iterations.
|
||||
|
||||
var options = new LightGbmMulticlassTrainer.Options
|
||||
{
|
||||
MaximumBinCountPerFeature = 8,
|
||||
LearningRate = 0.00025,
|
||||
NumberOfIterations = 40000,
|
||||
NumberOfLeaves = 10,
|
||||
LabelColumnName = "Fertilizer_NameF",
|
||||
FeatureColumnName = "Features",
|
||||
|
||||
Booster = new DartBooster.Options()
|
||||
{
|
||||
MaximumTreeDepth = 10
|
||||
}
|
||||
};
|
||||
|
||||
Creating pipeline for the model:
|
||||
|
||||
var pipeline = mlContext.Transforms
|
||||
.Text.FeaturizeText("Soil_TypeF", "Soil_Type")
|
||||
.Append(mlContext.Transforms.Text.FeaturizeText("Crop_TypeF", "Crop_Type"))
|
||||
.Append(mlContext.Transforms.Concatenate("Features", "Temperature", "Humidity", "Moisture", "Soil_TypeF", "Crop_TypeF", "Nitrogen", "Potassium", "Phosphorous"))
|
||||
.Append(mlContext.Transforms.Conversion.MapValueToKey("Fertilizer_NameF", "Fertilizer_Name"), TransformerScope.TrainTest)
|
||||
.AppendCacheCheckpoint(mLContext)
|
||||
.Append(mLContext.MulticlassClassification.Trainers.LightGbm(options))
|
||||
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel", "PredictedLabel"));
|
||||
|
||||
Evaluation of the pipeline is done with cross-validation method with 10 folds.
|
||||
Results are as follow:
|
||||
|
||||
Micro Accuracy: 0.95829
|
||||
LogLoss Average: 0.100171
|
||||
LogLoss Reduction: 0.933795
|
||||
|
||||
Model is created and saved for later use, to skip long trainig and evaluation times.
|
||||
Later that model is loaded and prediction engine is created when program is started.
|
||||
|
||||
|
||||
## Integration Details
|
||||
|
||||
Agent (tractor) navigates trough the grid looking for tiles where it can plant some plants.
|
||||
Upon planting and visitin already growing plants agent decides if any fertilizer is needed (rule based decision), and what fertilizer to use (using ML prediction engine).
|
||||
|
||||
if (farm.getCrop(x, y).getStatus() >= 2)
|
||||
{
|
||||
fertilizer = fertilizerHolder.GetFertilizer(Engine.PredictFertilizer(farm.getCrop(x, y), farm.getPresetCropTypes(farm.getCrop(x, y).getCropType())));
|
||||
while (!(farm.getCrop(x, y).isSaturated(-1)) && farm.getCrop(x, y).belowCapacity() && inventory.useItem(fertilizerHolder.GetFertilizerID(fertilizer.Name), 0))
|
||||
{
|
||||
farm.getCrop(x, y).Fertilize(fertilizer);
|
||||
fertilizer = fertilizerHolder.GetFertilizer(Engine.PredictFertilizer(farm.getCrop(x, y), farm.getPresetCropTypes(farm.getCrop(x, y).getCropType())));
|
||||
WaitTwoFrames = true;
|
||||
}
|
||||
|
||||
If field is properly fertilized it will have higher production rate, resulting in faster growth of a plant.
|
||||
Production rate value is shown in the UI as well as it is represented by the colour of progression bar (right side of every tile).
|
||||
At 100% bar will pure **Green**. Any value below will make bar more **Red**, while any value above will add **Blue**, eventually turning bar colour into cyan.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
![Progression Bar](https://git.wmi.amu.edu.pl/s425077/PotatoPlan/raw/Oskar-ML/example_img.jpg)
|
||||
|
BIN
example_img.jpg
Normal file
BIN
example_img.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue
Block a user