1
0
forked from s425077/PotatoPlan

bugfixes, finetuning

This commit is contained in:
BOTLester 2020-05-10 18:17:53 +02:00
parent aee7262c45
commit ef1e640f9e
5 changed files with 53 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -258,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);
}

View File

@ -161,15 +161,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));
}
}
@ -232,22 +232,46 @@ class Crops
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) * 2;
g = 0.0f + productionRate;
b = 0.0f + (float)Math.Pow((double)overhead * 10, 2);
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);
if (ProductionRate < 0)
{
ProductionRate = 0;
}
ProductionRate = ProductionRate / 10;
ProductionRate = ProductionRate / 1.5f;
}
return ProductionRate;
}

View File

@ -46,4 +46,9 @@ class PriorityQueueC5
queue.AddAll(entryList);
}
public int getCount()
{
return queue.Count();
}
}

View File

@ -53,6 +53,11 @@ class AI
int count = 0;
int testsize = 2;
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())
{
@ -81,8 +86,18 @@ class AI
}
if (count > 0)
break;
else if (queue.getCount() == 0)
{
astar.update(farm.getCrops(), Size, tractorPos, housePos, nodes.getCords(), Rotation);
return newTarget = astar.FindPath(true);
}
else //if (tractorPos != housePos)
return newTarget = GetMaxFNode(testsize, queue);
return newTarget = GetMaxFNode(Math.Min(queue.getCount(), testsize), queue);
}
if (queue.getCount() == 0)
{
astar.update(farm.getCrops(), Size, tractorPos, housePos, nodes.getCords(), Rotation);
return newTarget = astar.FindPath(true);
}
newTarget = GetMinFNode(Math.Min(testsize, count), queue);
queue = null;