This commit is contained in:
ryuga4 2019-05-04 15:53:04 +02:00
parent 2b996b21ee
commit 1afa3fdb70
3 changed files with 51 additions and 12 deletions

View File

@ -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
{
}
}

View File

@ -50,7 +50,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
}
List<IStep> PossibleSteps(ContentManager content, AGarbageCollector collector, ICloneable[,] grid)
List<IStep> PossibleSteps(AGarbageCollector collector, ICloneable[,] grid)
{
@ -125,7 +125,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
KeyValuePair<List<IStep>, 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<List<IStep>, 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<List<IStep>, int>(new List<IStep>(), 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)];

View File

@ -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<IStep> 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);