Final ProductionRate
This commit is contained in:
parent
bfad241a74
commit
fe35083968
@ -199,12 +199,12 @@ class Crops
|
||||
ProductionRate = 1;
|
||||
if (DataSet != null)
|
||||
{
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, DataSet.Temparature));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, DataSet.Moisture));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, DataSet.Humidity));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Phosphorous, DataSet.Phosphorous));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Potassium, DataSet.Potassium));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Nitrogen, DataSet.Nitrogen));
|
||||
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.Phosphorous, Sample.Phosphorous));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Potassium, Sample.Potassium));
|
||||
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Nitrogen, Sample.Nitrogen));
|
||||
if (ProductionRate < 0)
|
||||
{
|
||||
ProductionRate = 0;
|
||||
|
@ -20,9 +20,9 @@ class Farm
|
||||
PresetCrops.init();
|
||||
r = new Random();
|
||||
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);
|
||||
if (x == 0)
|
||||
@ -106,14 +106,29 @@ class Farm
|
||||
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
|
||||
{
|
||||
if (getProductionRate(x, y, i) > holder);
|
||||
holder = getProductionRate(x, y, i);
|
||||
if (SampleHolder < holder)
|
||||
{
|
||||
holderIndex = i;
|
||||
SampleHolder = holder;
|
||||
}
|
||||
i++;
|
||||
} while (i < 12);
|
||||
|
@ -34,9 +34,8 @@ class AI
|
||||
inventory.addItem(7, 1);
|
||||
inventory.addItem(7, 1);
|
||||
inventory.addItem(10, 1);
|
||||
inventory.addItem(10, 1);
|
||||
inventory.addItem(10, 1);
|
||||
inventory.useItem(10, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,10 +17,10 @@ class SmartTractor
|
||||
public Path returnChoice()
|
||||
{
|
||||
ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
|
||||
farm.UpdatePreferedCrops(Size);
|
||||
farm = ai.changeCropStatus();
|
||||
getTargetPosition(ai.newTarget());
|
||||
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target/(tileSize+Spacing), Rotation);
|
||||
|
||||
return astar.FindPath();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user