From 6f81261072ee5cb4fc2fd1c33303ebf5d5da3b41 Mon Sep 17 00:00:00 2001 From: ryuga4 Date: Sun, 5 May 2019 17:54:12 +0200 Subject: [PATCH 1/5] c5 --- Trunk/MonoGameView/Algorithms/BFS.cs | 10 ++++----- Trunk/MonoGameView/Algorithms/DFS.cs | 8 +++---- .../DataModels/Interfaces/IStep.cs | 3 ++- Trunk/MonoGameView/DataModels/Models/House.cs | 2 +- .../DataModels/Models/Steps/CollectStep.cs | 2 +- .../DataModels/Models/Steps/MoveStep.cs | 10 ++++----- .../DataModels/Models/Steps/SpillStep.cs | 2 +- Trunk/MonoGameView/Game1.cs | 21 ++++++++++--------- Trunk/MonoGameView/MonoGameView.csproj | 7 +++++++ Trunk/MonoGameView/packages.config | 4 ++++ 10 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 Trunk/MonoGameView/packages.config diff --git a/Trunk/MonoGameView/Algorithms/BFS.cs b/Trunk/MonoGameView/Algorithms/BFS.cs index 14ab60a..3473ce8 100644 --- a/Trunk/MonoGameView/Algorithms/BFS.cs +++ b/Trunk/MonoGameView/Algorithms/BFS.cs @@ -55,8 +55,8 @@ namespace MonoGameView.Algorithms var result = new List(); - - if (!(collector.TrashContainers.Any(x => x.FillPercent > 0) && grid[collector.Coords.X, collector.Coords.Y] is ADump)) + var itemdupa = grid[collector.Coords.X, collector.Coords.Y]; + if (!(itemdupa is House && collector.TrashContainers.All(i=>i.FillPercent==0))) { var moveSteps = new List() { @@ -141,15 +141,15 @@ namespace MonoGameView.Algorithms var nodes2 = new List, GarbageCollector, ICloneable[,]>>(); foreach (var item in nodes) { - Thread.Sleep(100); - this.Collector.Coords = item.Item2.Coords; + // Thread.Sleep(100); + /*this.Collector.Coords = item.Item2.Coords; for (int x = 0; x < item.Item3.GetLength(0); x++) { for (int y = 0; y < item.Item3.GetLength(1); y++) { this.Grid[x, y] = item.Item3[x, y]; } - } + }*/ if (Houses.All(c => (item.Item3[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0)) && diff --git a/Trunk/MonoGameView/Algorithms/DFS.cs b/Trunk/MonoGameView/Algorithms/DFS.cs index ab7dbf0..26ba707 100644 --- a/Trunk/MonoGameView/Algorithms/DFS.cs +++ b/Trunk/MonoGameView/Algorithms/DFS.cs @@ -126,8 +126,8 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms KeyValuePair, int> Search(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length) { - //Thread.Sleep(1); - this.Collector.Coords = collector.Coords; + //Thread.Sleep(100); + /*this.Collector.Coords = collector.Coords; for (int x = 0; x < grid.GetLength(0); x++) { for (int y = 0; y < grid.GetLength(1); y++) @@ -135,10 +135,10 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms this.Grid[x, y] = grid[x, y]; } } - + */ Console.WriteLine(collector.HouseCounter); - if (collector.Counter> 15 || length > 100) + if (collector.Counter> 100 || length > 100) return new KeyValuePair, int>(null,length); count++; if (Houses.All(c => (grid[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0)) diff --git a/Trunk/MonoGameView/DataModels/Interfaces/IStep.cs b/Trunk/MonoGameView/DataModels/Interfaces/IStep.cs index cc5c983..ac857b8 100644 --- a/Trunk/MonoGameView/DataModels/Interfaces/IStep.cs +++ b/Trunk/MonoGameView/DataModels/Interfaces/IStep.cs @@ -1,9 +1,10 @@ using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector; +using System; namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces { public interface IStep { - bool Invoke(IGarbageCollector collector, object [,] grid); + bool Invoke(IGarbageCollector collector, ICloneable [,] grid); } } diff --git a/Trunk/MonoGameView/DataModels/Models/House.cs b/Trunk/MonoGameView/DataModels/Models/House.cs index 5568c56..4d53800 100644 --- a/Trunk/MonoGameView/DataModels/Models/House.cs +++ b/Trunk/MonoGameView/DataModels/Models/House.cs @@ -28,7 +28,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models } public object Clone() - { + { return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList()); } diff --git a/Trunk/MonoGameView/DataModels/Models/Steps/CollectStep.cs b/Trunk/MonoGameView/DataModels/Models/Steps/CollectStep.cs index 21085d8..8b89df3 100644 --- a/Trunk/MonoGameView/DataModels/Models/Steps/CollectStep.cs +++ b/Trunk/MonoGameView/DataModels/Models/Steps/CollectStep.cs @@ -21,7 +21,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps private GarbageType _typeOfGarbage; - public bool Invoke(IGarbageCollector _garbageCollector, object [,] grid) + public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid) { var _garbageLocalization = (IGarbageLocalization) grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y]; diff --git a/Trunk/MonoGameView/DataModels/Models/Steps/MoveStep.cs b/Trunk/MonoGameView/DataModels/Models/Steps/MoveStep.cs index 1bd790c..f03deb6 100644 --- a/Trunk/MonoGameView/DataModels/Models/Steps/MoveStep.cs +++ b/Trunk/MonoGameView/DataModels/Models/Steps/MoveStep.cs @@ -20,7 +20,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps private Direction _direction; private IGarbageCollector _garbageCollector; - public bool Invoke(IGarbageCollector _garbageCollector, object[,] grid) + public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid) { if(grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] is Road1) grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] = new Road2(new Coords(_garbageCollector.Coords.X, _garbageCollector.Coords.Y)); @@ -28,17 +28,17 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps switch (_direction) { case Direction.Up: - pass = _garbageCollector.MoveDown(); + pass = _garbageCollector.MoveUp(); break; case Direction.Down: - pass = _garbageCollector.MoveRight(); + pass = _garbageCollector.MoveDown(); break; case Direction.Left: - pass = _garbageCollector.MoveUp(); + pass = _garbageCollector.MoveLeft(); break; case Direction.Right: - pass = _garbageCollector.MoveLeft(); + pass = _garbageCollector.MoveRight(); break; } if (pass) diff --git a/Trunk/MonoGameView/DataModels/Models/Steps/SpillStep.cs b/Trunk/MonoGameView/DataModels/Models/Steps/SpillStep.cs index 7028bcb..d6278df 100644 --- a/Trunk/MonoGameView/DataModels/Models/Steps/SpillStep.cs +++ b/Trunk/MonoGameView/DataModels/Models/Steps/SpillStep.cs @@ -20,7 +20,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps private GarbageType _typeOfGarbage; - public bool Invoke(IGarbageCollector _garbageCollector, object [,] grid) + public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid) { var _dump = (ADump)grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y]; diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index c42765a..1acc259 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using CzokoŚmieciarka.MonoGameView.Algorithms; using MonoGameView.DataModels; @@ -32,7 +33,7 @@ namespace CzokoŚmieciarka.MonoGameView MapLoader mapLoader = new MapLoader(); Vector2 roadPos; float timer; - const float TIMER = 1f; + const float TIMER = 0.1f; int stepN; List steps; GarbageCollector collector; @@ -60,7 +61,7 @@ namespace CzokoŚmieciarka.MonoGameView // TODO: Add your initialization logic here timer = 0f; - mapLoader.Load(out size,out grid,"map1.xml"); + mapLoader.Load(out size,out grid,"map2.xml"); var containers = new List() { new GarbageCollectorContainer( @@ -89,12 +90,12 @@ namespace CzokoŚmieciarka.MonoGameView stepN = 0; - var dfs = new BFS(collector,grid); - //steps = dfs.BestPath(Content, collector, grid); - new Thread(delegate() { - var x = dfs.BestPath(Content, collector, grid); + var dfs = new DFS(collector,grid); + steps = dfs.BestPath(Content, collector, grid); + //new Thread(delegate() { + // var x = dfs.BestPath(Content, collector, grid); - }).Start(); + //}).Start(); base.Initialize(); } @@ -131,7 +132,7 @@ namespace CzokoŚmieciarka.MonoGameView if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); - /*var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; + var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; timer -= elapsed; if (timer<0) { @@ -141,7 +142,7 @@ namespace CzokoŚmieciarka.MonoGameView steps.First().Invoke(collector, grid); steps.RemoveAt(0); } - }*/ + } // TODO: Add your update logic here @@ -171,7 +172,7 @@ namespace CzokoŚmieciarka.MonoGameView collector.Draw(spriteBatch, size); Display(new Dictionary(){["Dupa"] = "123", ["Stefan"] = "555", ["Dupa1"] = "123", ["Stefan1"] = "555", ["Dupa2"] = "123", ["Stefan2"] = "555"}); - + Debug.WriteLine("cycki dupa, chuj biskupa"); spriteBatch.End(); // TODO: Add your drawing code here diff --git a/Trunk/MonoGameView/MonoGameView.csproj b/Trunk/MonoGameView/MonoGameView.csproj index a966011..a2ca8c1 100644 --- a/Trunk/MonoGameView/MonoGameView.csproj +++ b/Trunk/MonoGameView/MonoGameView.csproj @@ -41,6 +41,9 @@ app.manifest + + + @@ -88,6 +91,9 @@ + + ..\packages\C5.2.5.3\lib\net45\C5.dll + $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll @@ -101,6 +107,7 @@ + diff --git a/Trunk/MonoGameView/packages.config b/Trunk/MonoGameView/packages.config new file mode 100644 index 0000000..ec72072 --- /dev/null +++ b/Trunk/MonoGameView/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 8d1f79e6625de0027fc4d7fe716982c09f5ab777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulski?= Date: Sat, 11 May 2019 15:14:40 +0200 Subject: [PATCH 2/5] s --- Trunk/MonoGameView/DataModels/Models/House.cs | 2 +- Trunk/MonoGameView/Game1.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Trunk/MonoGameView/DataModels/Models/House.cs b/Trunk/MonoGameView/DataModels/Models/House.cs index 4d53800..5568c56 100644 --- a/Trunk/MonoGameView/DataModels/Models/House.cs +++ b/Trunk/MonoGameView/DataModels/Models/House.cs @@ -28,7 +28,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models } public object Clone() - { + { return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList()); } diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index 1acc259..feffbba 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using CzokoŚmieciarka.MonoGameView.Algorithms; using MonoGameView.DataModels; @@ -172,7 +171,7 @@ namespace CzokoŚmieciarka.MonoGameView collector.Draw(spriteBatch, size); Display(new Dictionary(){["Dupa"] = "123", ["Stefan"] = "555", ["Dupa1"] = "123", ["Stefan1"] = "555", ["Dupa2"] = "123", ["Stefan2"] = "555"}); - Debug.WriteLine("cycki dupa, chuj biskupa"); + spriteBatch.End(); // TODO: Add your drawing code here From 0d840d4a775b47135288a5abe3aa8089d3ca58f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulski?= Date: Sat, 11 May 2019 16:03:29 +0200 Subject: [PATCH 3/5] =?UTF-8?q?zal=C4=85=C5=BCek=20wy=C5=9Bwietlania=20inf?= =?UTF-8?q?o=20o=20domkach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Trunk/MonoGameView/DataModels/Displayer.cs | 13 +++++++++++++ Trunk/MonoGameView/Game1.cs | 21 ++++++++++++++++++++- Trunk/MonoGameView/MonoGameView.csproj | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Trunk/MonoGameView/DataModels/Displayer.cs diff --git a/Trunk/MonoGameView/DataModels/Displayer.cs b/Trunk/MonoGameView/DataModels/Displayer.cs new file mode 100644 index 0000000..c734f44 --- /dev/null +++ b/Trunk/MonoGameView/DataModels/Displayer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MonoGameView.DataModels +{ + public class Displayer + { + public Dictionary Content { get; set; } + } +} diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index feffbba..03b97d6 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using System; +using System.CodeDom; using System.Collections.Generic; using System.Linq; using CzokoŚmieciarka.MonoGameView.Algorithms; @@ -37,6 +38,9 @@ namespace CzokoŚmieciarka.MonoGameView List steps; GarbageCollector collector; IDrawables[,] grid; + Displayer displayer = new Displayer(){Content = new Dictionary()}; + + public Game1() { graphics = new GraphicsDeviceManager(this); @@ -169,8 +173,23 @@ namespace CzokoŚmieciarka.MonoGameView } } collector.Draw(spriteBatch, size); - Display(new Dictionary(){["Dupa"] = "123", ["Stefan"] = "555", ["Dupa1"] = "123", ["Stefan1"] = "555", ["Dupa2"] = "123", ["Stefan2"] = "555"}); + displayer.Content = new Dictionary(); + try + { + foreach (var item in grid) + { + if (item is House) + { + var house = item as House; + displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString(), house.TrashCans.LastOrDefault().FillPercent.ToString()); + } + } + } + catch + { + } + Display(displayer.Content); spriteBatch.End(); // TODO: Add your drawing code here diff --git a/Trunk/MonoGameView/MonoGameView.csproj b/Trunk/MonoGameView/MonoGameView.csproj index a2ca8c1..7deca05 100644 --- a/Trunk/MonoGameView/MonoGameView.csproj +++ b/Trunk/MonoGameView/MonoGameView.csproj @@ -47,6 +47,7 @@ + From 9669431c3ae2753a07ddc9709e958d68815cac1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulski?= Date: Sun, 12 May 2019 13:49:19 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Poziom=20zape=C5=82nienia=20niekt=C3=B3rych?= =?UTF-8?q?=20=C5=9Bmietnik=C3=B3w=20z=20dom=C3=B3w=20nie=20dodaje=20si?= =?UTF-8?q?=C4=99=20do=20displayera?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Trunk/MonoGameView/Game1.cs | 5 +- Trunk/MonoGameView/map2.xml | 168 ++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-) diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index 03b97d6..0402d5d 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -181,7 +181,10 @@ namespace CzokoŚmieciarka.MonoGameView if (item is House) { var house = item as House; - displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString(), house.TrashCans.LastOrDefault().FillPercent.ToString()); + displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "1", house.TrashCans.ElementAtOrDefault(0).Garbage.Volume.ToString()); + //displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "2", house.TrashCans.ElementAtOrDefault(1).Garbage.Volume.ToString()); + //displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "3", house.TrashCans.ElementAtOrDefault(2).Garbage.Volume.ToString()); + //displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "4", house.TrashCans.ElementAtOrDefault(3).Garbage.Volume.ToString()); } } } diff --git a/Trunk/MonoGameView/map2.xml b/Trunk/MonoGameView/map2.xml index cc4236f..d632bdf 100644 --- a/Trunk/MonoGameView/map2.xml +++ b/Trunk/MonoGameView/map2.xml @@ -174,6 +174,48 @@ 100 + + + Organic + + + 1 + + + 1 + + + 100 + + + + + Paper + + + 1 + + + 1 + + + 100 + + + + + PlasticMetal + + + 1 + + + 1 + + + 100 + + @@ -280,6 +322,48 @@ 100 + + + + Organic + + + 1 + + + 1 + + + 100 + + + + + Paper + + + 1 + + + 1 + + + 100 + + + + + PlasticMetal + + + 1 + + + 1 + + + 100 + @@ -1171,6 +1255,48 @@ 100 + + + + Organic + + + 1 + + + 1 + + + 100 + + + + + Paper + + + 1 + + + 1 + + + 100 + + + + + PlasticMetal + + + 1 + + + 1 + + + 100 + @@ -1278,6 +1404,48 @@ 100 + + + + Organic + + + 1 + + + 1 + + + 100 + + + + + Paper + + + 1 + + + 1 + + + 100 + + + + + PlasticMetal + + + 1 + + + 1 + + + 100 + From 42180bf440a6202681a88c94ee0950aa5614cc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulski?= Date: Mon, 13 May 2019 15:19:24 +0200 Subject: [PATCH 5/5] =?UTF-8?q?wy=C5=9Bwietlanie=20zawarto=C5=9Bci=20?= =?UTF-8?q?=C5=9Bmietnik=C3=B3w=20w=20domach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Trunk/MonoGameView/Game1.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index 0402d5d..29f4f8c 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -181,10 +181,10 @@ namespace CzokoŚmieciarka.MonoGameView if (item is House) { var house = item as House; - displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "1", house.TrashCans.ElementAtOrDefault(0).Garbage.Volume.ToString()); - //displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "2", house.TrashCans.ElementAtOrDefault(1).Garbage.Volume.ToString()); - //displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "3", house.TrashCans.ElementAtOrDefault(2).Garbage.Volume.ToString()); - //displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + "4", house.TrashCans.ElementAtOrDefault(3).Garbage.Volume.ToString()); + displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + house.TrashCans.ElementAtOrDefault(0).Garbage.TypeOfGarbage.GarbageType.ToString(), house.TrashCans.ElementAtOrDefault(0).Garbage.Volume.ToString()); + displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + house.TrashCans.ElementAtOrDefault(1).Garbage.TypeOfGarbage.GarbageType.ToString(), house.TrashCans.ElementAtOrDefault(1).Garbage.Volume.ToString()); + displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + house.TrashCans.ElementAtOrDefault(2).Garbage.TypeOfGarbage.GarbageType.ToString(), house.TrashCans.ElementAtOrDefault(2).Garbage.Volume.ToString()); + displayer.Content.Add(house.Coords.X.ToString() + ":" + house.Coords.Y.ToString() + house.TrashCans.ElementAtOrDefault(3).Garbage.TypeOfGarbage.GarbageType.ToString(), house.TrashCans.ElementAtOrDefault(3).Garbage.Volume.ToString()); } } }