Final ProductionRate
This commit is contained in:
parent
bfad241a74
commit
fe35083968
@ -199,12 +199,12 @@ class Crops
|
|||||||
ProductionRate = 1;
|
ProductionRate = 1;
|
||||||
if (DataSet != null)
|
if (DataSet != null)
|
||||||
{
|
{
|
||||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, DataSet.Temparature));
|
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, Sample.Temparature));
|
||||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, DataSet.Moisture));
|
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, Sample.Moisture));
|
||||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, DataSet.Humidity));
|
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, Sample.Humidity));
|
||||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Phosphorous, DataSet.Phosphorous));
|
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Phosphorous, Sample.Phosphorous));
|
||||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Potassium, DataSet.Potassium));
|
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Potassium, Sample.Potassium));
|
||||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Nitrogen, DataSet.Nitrogen));
|
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Nitrogen, Sample.Nitrogen));
|
||||||
if (ProductionRate < 0)
|
if (ProductionRate < 0)
|
||||||
{
|
{
|
||||||
ProductionRate = 0;
|
ProductionRate = 0;
|
||||||
|
@ -20,9 +20,9 @@ class Farm
|
|||||||
PresetCrops.init();
|
PresetCrops.init();
|
||||||
r = new Random();
|
r = new Random();
|
||||||
crops = new Crops[100, 100];
|
crops = new Crops[100, 100];
|
||||||
for (int i = 0; i < Size.X; i++)
|
for (int i = 0; i < 99; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < Size.Y; j++)
|
for (int j = 0; j < 99; j++)
|
||||||
{
|
{
|
||||||
int x = r.Next(0, 3);
|
int x = r.Next(0, 3);
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
@ -106,14 +106,29 @@ class Farm
|
|||||||
crops[x, y].setCropType(Type, PresetCrops.getPresetCropTypes(Type));
|
crops[x, y].setCropType(Type, PresetCrops.getPresetCropTypes(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHighestProductionRate(int x, int y)
|
public void UpdatePreferedCrops(Vector2 Size)
|
||||||
{
|
{
|
||||||
int i = 1, holder = 0, holderIndex;
|
for (int i = 0; i < Size.X; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < Size.X; j++)
|
||||||
|
{
|
||||||
|
int x = getHighestProductionRate(i, j);
|
||||||
|
crops[i,j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getHighestProductionRate(int x, int y)
|
||||||
|
{
|
||||||
|
int i = 1, holderIndex = 0;
|
||||||
|
float holder = 0, SampleHolder = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (getProductionRate(x, y, i) > holder);
|
holder = getProductionRate(x, y, i);
|
||||||
|
if (SampleHolder < holder)
|
||||||
{
|
{
|
||||||
holderIndex = i;
|
holderIndex = i;
|
||||||
|
SampleHolder = holder;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} while (i < 12);
|
} while (i < 12);
|
||||||
|
@ -36,7 +36,6 @@ class AI
|
|||||||
inventory.addItem(10, 1);
|
inventory.addItem(10, 1);
|
||||||
inventory.addItem(10, 1);
|
inventory.addItem(10, 1);
|
||||||
inventory.useItem(10, 1);
|
inventory.useItem(10, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ class SmartTractor
|
|||||||
public Path returnChoice()
|
public Path returnChoice()
|
||||||
{
|
{
|
||||||
ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
|
ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
|
||||||
|
farm.UpdatePreferedCrops(Size);
|
||||||
farm = ai.changeCropStatus();
|
farm = ai.changeCropStatus();
|
||||||
getTargetPosition(ai.newTarget());
|
getTargetPosition(ai.newTarget());
|
||||||
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target/(tileSize+Spacing), Rotation);
|
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target/(tileSize+Spacing), Rotation);
|
||||||
|
|
||||||
return astar.FindPath();
|
return astar.FindPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user