diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index 1be67d0..d99aa3b 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -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; diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index 6167cd7..6340681 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -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); diff --git a/Game1/Sources/Smart/AI.cs b/Game1/Sources/Smart/AI.cs index 38410a7..34f7d0d 100644 --- a/Game1/Sources/Smart/AI.cs +++ b/Game1/Sources/Smart/AI.cs @@ -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); - } diff --git a/Game1/Sources/Smart/SmartTractor.cs b/Game1/Sources/Smart/SmartTractor.cs index 74f5dae..4a909d7 100644 --- a/Game1/Sources/Smart/SmartTractor.cs +++ b/Game1/Sources/Smart/SmartTractor.cs @@ -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(); }