From eb99fd3f027b025b52ab2da0e961d520431503e1 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 24 May 2020 16:51:29 +0200 Subject: [PATCH 1/3] gtyhsy --- Game1/Sources/Crops/Farm.cs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index c9928c3..c6e2067 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -72,8 +72,8 @@ class Farm init(Size, housepos); RainPosition.X = r.Next(0, 1900); RainPosition.Y = r.Next(0, 1950); - RainPosition.X = 5; - RainPosition.Y = 5; + RainPosition.X = 1980; + RainPosition.Y = 800; RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png"); } @@ -99,10 +99,10 @@ class Farm public Rectangle getDestinationRectangle(int x, int y, Vector2 Size) { Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); - if (RainPosition.X >= 1999 - Size.X) - temp.X = (Size.X) - (1999 - (int)Math.Round(RainPosition.X)); - if (RainPosition.Y >= 1999 - Size.Y) - temp.Y = (Size.Y) - (1999 - (int)Math.Round(RainPosition.Y)); + if (RainPosition.X >= 1999 - Size.X - 1) + temp.X = (1999 - (int)Math.Round(RainPosition.X)); + if (RainPosition.Y >= 1999 - Size.Y - 1) + temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); return new Rectangle(x + (int)temp.X, y + (int)temp.Y, 1, 1); } @@ -123,10 +123,10 @@ class Farm for (int j = 0; j < Size.Y; j++) { Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); - if (RainPosition.X >= 1999 - Size.X) - temp.X = (Size.X) - (1999 - (int)Math.Round(RainPosition.X)); - if (RainPosition.Y >= 1999 - Size.Y) - temp.Y = (Size.Y) - (1999 - (int)Math.Round(RainPosition.Y)); + if (RainPosition.X >= 1999 - Size.X - 1) + temp.X = (1999 - (int)Math.Round(RainPosition.X)); + if (RainPosition.Y >= 1999 - Size.Y - 1) + temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X) + i][(int)Math.Round(temp.Y) + j].GetBrightness()); } } @@ -173,7 +173,7 @@ class Farm float x, y; x = WindSpeed.X + GetRandomNumber(-1f, 1f) / 2000; y = WindSpeed.Y + GetRandomNumber(-1f, 1f) / 2000; - x = -0.02f; + x = 0.02f; if (x <= 1f && x >= -1f) { WindSpeed.X = x; @@ -255,10 +255,12 @@ class Farm public Color getRainAmount(int x, int y, Color color, Vector2 Size) { Vector2 temp = new Vector2(x + (int)Math.Round(RainPosition.X), y + (int)Math.Round(RainPosition.Y)); - if (RainPosition.X >= 1999 - Size.X) - temp.X = (Size.X) - (1999 - (int)Math.Round(RainPosition.X)); - if (RainPosition.Y >= 1999 - Size.Y) - temp.Y = (Size.Y) - (1999 - (int)Math.Round(RainPosition.Y)); + if (RainPosition.X >= 1999 - Size.X - 1) + temp.X = (1999 - (int)Math.Round(RainPosition.X) + x); + if (RainPosition.Y >= 1999 - Size.Y - 1) + temp.Y = (1999 - (int)Math.Round(RainPosition.Y) + y); + if (temp.X == -1) + temp.X = 1999; if (RainfallMap[(int)temp.X][(int)temp.Y].GetBrightness() < 0.4f) { return Color.FromNonPremultiplied(color.R, color.G, color.B, (int)(0)); From 0a31c36c93162254f4f9c3e4708f46caa8b971a6 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 24 May 2020 17:08:41 +0200 Subject: [PATCH 2/3] asd --- Game1/Sources/Crops/Crops.cs | 1 + Game1/Sources/Crops/Farm.cs | 14 +++++++------- Game1/Sources/ML/MLModel.cs | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index 5f97d26..497ca7a 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -272,6 +272,7 @@ class Crops housePos = state; if (state) { + Timer = 1; Status = 1; } else diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index 052e438..5d9dd20 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -75,7 +75,7 @@ class Farm RainPosition.X = 1980; RainPosition.Y = 800; RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png"); - RainfallMap = PerlinNoise.LoadImage("C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/Rainfall.png"); + //RainfallMap = PerlinNoise.LoadImage("C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/Rainfall.png"); } public Rectangle getRainPosition(int TileSize, int x, int y) @@ -100,9 +100,9 @@ class Farm public Rectangle getDestinationRectangle(int x, int y, Vector2 Size) { Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); - if (RainPosition.X >= 1999 - Size.X - 1) + if (temp.X >= 1999 - Size.X - 1) temp.X = (1999 - (int)Math.Round(RainPosition.X)); - if (RainPosition.Y >= 1999 - Size.Y - 1) + if (temp.Y >= 1999 - Size.Y - 1) temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); return new Rectangle(x + (int)temp.X, y + (int)temp.Y, 1, 1); } @@ -124,9 +124,9 @@ class Farm for (int j = 0; j < Size.Y; j++) { Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); - if (RainPosition.X >= 1999 - Size.X - 1) + if (temp.X >= 1999 - Size.X - 1) temp.X = (1999 - (int)Math.Round(RainPosition.X)); - if (RainPosition.Y >= 1999 - Size.Y - 1) + if (temp.Y >= 1999 - Size.Y - 1) temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X) + i][(int)Math.Round(temp.Y) + j].GetBrightness()); } @@ -256,9 +256,9 @@ class Farm public Color getRainAmount(int x, int y, Color color, Vector2 Size) { Vector2 temp = new Vector2(x + (int)Math.Round(RainPosition.X), y + (int)Math.Round(RainPosition.Y)); - if (RainPosition.X >= 1999 - Size.X - 1) + if (temp.X >= 1999 - Size.X - 1) temp.X = (1999 - (int)Math.Round(RainPosition.X) + x); - if (RainPosition.Y >= 1999 - Size.Y - 1) + if (temp.Y >= 1999 - Size.Y - 1) temp.Y = (1999 - (int)Math.Round(RainPosition.Y) + y); if (temp.X == -1) temp.X = 1999; diff --git a/Game1/Sources/ML/MLModel.cs b/Game1/Sources/ML/MLModel.cs index ade70d5..5f524e1 100644 --- a/Game1/Sources/ML/MLModel.cs +++ b/Game1/Sources/ML/MLModel.cs @@ -20,9 +20,9 @@ class MLModel private static string modelpathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodelBig"; private static string reportBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_BigModel"; - private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Fertilizer_Prediction.csv"; - private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel"; - private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report"; + private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Fertilizer_Prediction.csv"; + private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel"; + private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report"; // Loading data, creatin and saving ML model for smaller dataset (100) public static void CreateModel() From 50fd54ee3b4f815d42782c811742cec99954f5bf Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 24 May 2020 18:49:23 +0200 Subject: [PATCH 3/3] asd --- Game1/Game1.cs | 2 +- Game1/Sources/Crops/Farm.cs | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Game1/Game1.cs b/Game1/Game1.cs index 606387c..c01ef1f 100644 --- a/Game1/Game1.cs +++ b/Game1/Game1.cs @@ -318,7 +318,7 @@ namespace Game1 { for (int j = -1; j < input.getSize().Y + 1; j++) { - spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j), tractorUnit.getFarm().getDestinationRectangle(i, j, input.getSize()), tractorUnit.getFarm().getRainAmount(i, j, Time.GetTimeOfDay(), input.getSize())); + spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j, input.getSize()), tractorUnit.getFarm().getDestinationRectangle(i, j, input.getSize()), tractorUnit.getFarm().getRainAmount(i, j, Time.GetTimeOfDay(), input.getSize())); } } diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index 5d9dd20..b92376b 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -72,14 +72,20 @@ class Farm init(Size, housepos); RainPosition.X = r.Next(0, 1900); RainPosition.Y = r.Next(0, 1950); - RainPosition.X = 1980; - RainPosition.Y = 800; + RainPosition.X = 1970; + RainPosition.Y = 155; RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png"); //RainfallMap = PerlinNoise.LoadImage("C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/Rainfall.png"); } - public Rectangle getRainPosition(int TileSize, int x, int y) + public Rectangle getRainPosition(int TileSize, int x, int y, Vector2 Size) { + Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); + if (temp.X >= 1999 - Size.X - 1) + temp.X = x + (1999 - (int)Math.Round(RainPosition.X) - Size.X); + if (temp.Y >= 1999 - Size.Y - 1) + temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); + float xtrunc = RainPosition.X - (float)Math.Truncate(RainPosition.X); float ytrunc = RainPosition.Y - (float)Math.Truncate(RainPosition.Y); @@ -99,12 +105,12 @@ class Farm public Rectangle getDestinationRectangle(int x, int y, Vector2 Size) { - Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); + Vector2 temp = new Vector2((int)Math.Round(x + RainPosition.X), y + (int)Math.Round(RainPosition.Y)); if (temp.X >= 1999 - Size.X - 1) - temp.X = (1999 - (int)Math.Round(RainPosition.X)); + temp.X = x + (1999 - (int)Math.Round(RainPosition.X)); if (temp.Y >= 1999 - Size.Y - 1) temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); - return new Rectangle(x + (int)temp.X, y + (int)temp.Y, 1, 1); + return new Rectangle((int)temp.X, (int)temp.Y, 1, 1); } public void drawWeatherInformation(SpriteBatch spriteBatch, SpriteFont Bold, Input input) @@ -123,12 +129,14 @@ class Farm { for (int j = 0; j < Size.Y; j++) { - Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y)); + Vector2 temp = new Vector2((int)Math.Round(i + RainPosition.X), j + (int)Math.Round(RainPosition.Y)); if (temp.X >= 1999 - Size.X - 1) - temp.X = (1999 - (int)Math.Round(RainPosition.X)); + temp.X = i + ((1999 - (int)Math.Round(RainPosition.X))); if (temp.Y >= 1999 - Size.Y - 1) temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); - crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X) + i][(int)Math.Round(temp.Y) + j].GetBrightness()); + if (temp.X == -1) + temp.X = 1999; + crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness()); } } @@ -196,12 +204,12 @@ class Farm RainPosition.Y = RainPosition.Y + WindSpeed.Y; if (Math.Round(RainPosition.X) == 1999 && WindSpeed.X > 0) - RainPosition.X = 1; + RainPosition.X = 0; else if (Math.Round(RainPosition.X) == 1 && WindSpeed.X < 0) RainPosition.X = 1999; if (Math.Round(RainPosition.Y) == 1999 - Size.Y - 1 && WindSpeed.Y > 0) - RainPosition.Y = 1; + RainPosition.Y = 0; if (Math.Round(RainPosition.Y) == 1 && WindSpeed.Y < 0) RainPosition.Y = 1999 - Size.Y - 1; } @@ -256,10 +264,10 @@ class Farm public Color getRainAmount(int x, int y, Color color, Vector2 Size) { Vector2 temp = new Vector2(x + (int)Math.Round(RainPosition.X), y + (int)Math.Round(RainPosition.Y)); - if (temp.X >= 1999 - Size.X - 1) - temp.X = (1999 - (int)Math.Round(RainPosition.X) + x); + if (temp.X >= 1999) + temp.X = -(1999 - (int)Math.Round(temp.X)); if (temp.Y >= 1999 - Size.Y - 1) - temp.Y = (1999 - (int)Math.Round(RainPosition.Y) + y); + temp.Y = (1999 - (int)Math.Round(RainPosition.Y)); if (temp.X == -1) temp.X = 1999; if (RainfallMap[(int)temp.X][(int)temp.Y].GetBrightness() < 0.4f)