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