forked from s425077/PotatoPlan
asd
This commit is contained in:
parent
c89fee6b05
commit
090a612660
@ -22,17 +22,17 @@ class Crops
|
||||
SoilProperties soilProperties = new SoilProperties();
|
||||
private float ProductionRate;
|
||||
private float tempRain;
|
||||
private float prevpred;
|
||||
private DayNightCycle Time = new DayNightCycle();
|
||||
|
||||
|
||||
|
||||
public void updateCrop(Vector2 newSize, float Rain, DayNightCycle nTime)
|
||||
public void updateCrop(Vector2 newSize, DayNightCycle nTime)
|
||||
{
|
||||
Time = nTime;
|
||||
tempRain = Rain;
|
||||
if (UpdateCrop == 60)
|
||||
{
|
||||
degradeSoil(Rain);
|
||||
degradeSoil();
|
||||
UpdateCrop = 0;
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ class Crops
|
||||
}
|
||||
}
|
||||
|
||||
public void degradeSoil(float Rain)
|
||||
public void degradeSoil()
|
||||
{
|
||||
|
||||
if (soilProperties.Nitrogen > 4.0f)
|
||||
@ -219,13 +219,14 @@ class Crops
|
||||
{
|
||||
soilProperties.Potassium = soilProperties.Potassium - (soilProperties.PotassiumDegradeRate * (float)Math.Pow(ProductionRate, 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateRainfall(float Rain)
|
||||
{
|
||||
if (Rain >= 0.45f)
|
||||
{
|
||||
soilProperties.Rainfall = soilProperties.Rainfall + Rain * 600;
|
||||
soilProperties.Rainfall = soilProperties.Rainfall + Rain * 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setPrevRainfall()
|
||||
@ -333,7 +334,7 @@ class Crops
|
||||
public float getProductionRate(CropTypes Sample)
|
||||
{
|
||||
float predProd = 1.0f;
|
||||
if (Status > 1)
|
||||
if (Status > 1 && Time.nDay())
|
||||
{
|
||||
bool correctSeason = false;
|
||||
foreach (string i in Sample.Season)
|
||||
@ -353,7 +354,7 @@ class Crops
|
||||
else
|
||||
predProd = 0.20f;
|
||||
}
|
||||
|
||||
prevpred = predProd;
|
||||
ProductionRate = 1;
|
||||
float min = 1.0f;
|
||||
if (DataSet != null)
|
||||
@ -392,7 +393,7 @@ class Crops
|
||||
ProductionRate = ProductionRate / 1.5f;
|
||||
}
|
||||
ProductionRate = (float)Math.Pow(ProductionRate, 2.5f);
|
||||
return ProductionRate * predProd;
|
||||
return ProductionRate * prevpred;
|
||||
}
|
||||
|
||||
public float getProductionRate()
|
||||
|
@ -50,7 +50,7 @@ class Farm
|
||||
crops[i, j] = new Crops();
|
||||
crops[i, j].setStatus(x);
|
||||
crops[i, j].setOriginalStatus();
|
||||
x = r.Next(0, 12);
|
||||
x = r.Next(1, 12);
|
||||
crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
||||
crops[i, j].init();
|
||||
|
||||
@ -131,12 +131,14 @@ class Farm
|
||||
temp.X = i + ((1999 - (int)Math.Round(RainPosition.X)));
|
||||
if (temp.Y >= 1999 - Size.Y - 1)
|
||||
temp.Y = i + ((1999 - (int)Math.Round(RainPosition.Y)));
|
||||
crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness(), Time);
|
||||
crops[i, j].updateCrop(Size, Time);
|
||||
crops[i, j].updateRainfall(RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness());
|
||||
}
|
||||
}
|
||||
|
||||
Update = 0;
|
||||
}
|
||||
updateRainMapPosition(Size);
|
||||
if (productionUpdate == 60)
|
||||
{
|
||||
nextUpdate = updateProgress + updatePerc;
|
||||
@ -144,7 +146,12 @@ class Farm
|
||||
{
|
||||
for (int j = 0; j < Size.Y; j++)
|
||||
{
|
||||
crops[i, j].updateProductionRate();
|
||||
if (crops[i, j].getStatus() > 1)
|
||||
{
|
||||
int x = getHighestProductionRate(i, j);
|
||||
crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
||||
crops[i, j].updateProductionRate();
|
||||
}
|
||||
}
|
||||
}
|
||||
updateProgress = updateProgress + updatePerc;
|
||||
@ -152,7 +159,6 @@ class Farm
|
||||
{
|
||||
updateProgress = 0;
|
||||
}
|
||||
updateRainMapPosition(Size);
|
||||
productionUpdate = 0;
|
||||
nextUpdate = 0;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ namespace Game1.Sources.ML_Joel
|
||||
|
||||
return PredictionEngineArea.Predict(modelInput).Score;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,25 +7,31 @@ using Microsoft.Xna.Framework;
|
||||
|
||||
class DayNightCycle
|
||||
{
|
||||
private bool Time = false;
|
||||
private bool Time = true;
|
||||
private bool Day = true;
|
||||
private int nightTime = 0;
|
||||
private int dayTime = 0;
|
||||
private int lengthOfDay = 20000;
|
||||
private int lengthOfNight = 20000;
|
||||
private int Days = 1;
|
||||
private int DaysOfYear = 0;
|
||||
private int speed = 1;
|
||||
private bool nextDay = true;
|
||||
|
||||
|
||||
public void updateTime(int Speed)
|
||||
{
|
||||
speed = Speed;
|
||||
Time = false;
|
||||
for (int i = 0; i < Speed; i++)
|
||||
{
|
||||
if (Time)
|
||||
if (Day)
|
||||
{
|
||||
dayTime++;
|
||||
if (dayTime == lengthOfDay)
|
||||
{
|
||||
Time = false;
|
||||
Day = false;
|
||||
dayTime = 0;
|
||||
}
|
||||
}
|
||||
@ -35,6 +41,7 @@ class DayNightCycle
|
||||
if (nightTime == lengthOfNight)
|
||||
{
|
||||
Time = true;
|
||||
Day = true;
|
||||
nightTime = 0;
|
||||
Days++;
|
||||
DaysOfYear++;
|
||||
@ -136,7 +143,7 @@ class DayNightCycle
|
||||
|
||||
public int GetTimeOfDayInt()
|
||||
{
|
||||
if (Time)
|
||||
if (Day)
|
||||
{
|
||||
return (int)(100 * ((float)(dayTime + nightTime) / (lengthOfDay + lengthOfNight))) + 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user