diff --git a/Trunk/MonoGameView/Algorithms/BFS.cs b/Trunk/MonoGameView/Algorithms/BFS.cs new file mode 100644 index 0000000..e6a73b8 --- /dev/null +++ b/Trunk/MonoGameView/Algorithms/BFS.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MonoGameView.Algorithms +{ + class BFS + { + } +} diff --git a/Trunk/MonoGameView/Algorithms/DFS.cs b/Trunk/MonoGameView/Algorithms/DFS.cs index 094ff89..ab7dbf0 100644 --- a/Trunk/MonoGameView/Algorithms/DFS.cs +++ b/Trunk/MonoGameView/Algorithms/DFS.cs @@ -50,7 +50,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms } - List PossibleSteps(ContentManager content, AGarbageCollector collector, ICloneable[,] grid) + List PossibleSteps(AGarbageCollector collector, ICloneable[,] grid) { @@ -125,7 +125,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms KeyValuePair, int> Search(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length) { - + //Thread.Sleep(1); this.Collector.Coords = collector.Coords; for (int x = 0; x < grid.GetLength(0); x++) @@ -135,10 +135,10 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms this.Grid[x, y] = grid[x, y]; } } - + Console.WriteLine(collector.HouseCounter); - if (collector.Counter> 10 || length > 55) + if (collector.Counter> 15 || 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)) @@ -149,7 +149,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms { return new KeyValuePair, int>(new List(), length); } - var possibleSteps = PossibleSteps(content, collector, grid); + var possibleSteps = PossibleSteps(collector, grid); foreach (var item in possibleSteps) { @@ -182,6 +182,30 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms } + + + + + + + + + + + + + + + + + + + + + + + + private ICloneable[,] CopyGrid(ICloneable[,] grid) { ICloneable[,] result = new ICloneable[grid.GetLength(0), grid.GetLength(1)]; diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index 1a1e39d..cb0c4a7 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -31,7 +31,7 @@ namespace CzokoŚmieciarka.MonoGameView MapLoader mapLoader = new MapLoader(); Vector2 roadPos; float timer; - const float TIMER = 0.02f; + const float TIMER = 1f; int stepN; List steps; GarbageCollector collector; @@ -84,13 +84,16 @@ namespace CzokoŚmieciarka.MonoGameView ), }; - collector = new GarbageCollector(new Coords(9,9), containers, size, size,0); + collector = new GarbageCollector(new Coords(0,0), containers, size, size,0); stepN = 0; var dfs = new DFS(collector,grid); //steps = dfs.BestPath(Content, collector, grid); - new Thread(delegate() { dfs.BestPath(Content, collector, grid); }).Start(); + new Thread(delegate() { + var x = dfs.BestPath(Content, collector, grid); + + }).Start(); base.Initialize(); } @@ -126,8 +129,8 @@ 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) { @@ -137,8 +140,8 @@ namespace CzokoŚmieciarka.MonoGameView steps.First().Invoke(collector, grid); steps.RemoveAt(0); } - } - */ + }*/ + // TODO: Add your update logic here base.Update(gameTime);