empty house naprawione

This commit is contained in:
ryuga4 2019-05-13 17:57:32 +02:00
parent b9771b34b6
commit 5997093c03
6 changed files with 13 additions and 12 deletions

View File

@ -126,8 +126,8 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
KeyValuePair<List<IStep>, int> Search(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length) KeyValuePair<List<IStep>, int> Search(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length)
{ {
//Thread.Sleep(100); Thread.Sleep(100);
this.Collector.Coords = collector.Coords; this.Collector.Coords = collector.Coords;
for (int x = 0; x < grid.GetLength(0); x++) for (int x = 0; x < grid.GetLength(0); x++)
@ -135,10 +135,11 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
for (int y = 0; y < grid.GetLength(1); y++) for (int y = 0; y < grid.GetLength(1); y++)
{ {
this.Grid[x, y] = grid[x, y]; this.Grid[x, y] = (ICloneable) grid[x, y].Clone();
} }
} }
Console.WriteLine(collector.HouseCounter); Console.WriteLine(collector.HouseCounter);
if (collector.Counter> 100 || length > 1000) if (collector.Counter> 100 || length > 1000)

View File

@ -12,6 +12,6 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
{ {
Coords Coords { get; } Coords Coords { get; }
IEnumerable<ATrashCan> TrashCans { get; set; } List<ATrashCan> TrashCans { get; }
} }
} }

View File

@ -28,10 +28,10 @@ namespace MonoGameView.DataModels.Models
public object Clone() public object Clone()
{ {
return new House((Coords)Coords.Clone(), new List<TrashCan>()); return new EmptyHouse((Coords)Coords.Clone());
} }
public IEnumerable<ATrashCan> TrashCans { get; set; } public List<ATrashCan> TrashCans { get; set; }
} }
} }

View File

@ -11,13 +11,13 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
{ {
public class GarbageLocalization : IGarbageLocalization public class GarbageLocalization : IGarbageLocalization
{ {
public GarbageLocalization(Coords coords, IEnumerable<ATrashCan> trashCans) public GarbageLocalization(Coords coords, List<ATrashCan> trashCans)
{ {
this.Coords = coords; this.Coords = coords;
this.TrashCans = trashCans; this.TrashCans = trashCans;
} }
public Coords Coords { get; } public Coords Coords { get; }
public IEnumerable<ATrashCan> TrashCans { get; set; } public List<ATrashCan> TrashCans { get; set; }
} }
} }

View File

@ -17,10 +17,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
{ {
public Coords Coords { get; } public Coords Coords { get; }
public House(Coords coords, IEnumerable<TrashCan> trashCans) public House(Coords coords, List<TrashCan> trashCans)
{ {
Coords = coords; Coords = coords;
TrashCans = trashCans; TrashCans = trashCans.Select(x=>(x as ATrashCan)).ToList();
} }
public void Draw(SpriteBatch batch, int size) public void Draw(SpriteBatch batch, int size)
{ {
@ -37,6 +37,6 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList()); return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList());
} }
public IEnumerable<ATrashCan> TrashCans { get; set; } public List<ATrashCan> TrashCans { get; }
} }
} }

View File

@ -93,7 +93,7 @@ namespace CzokoŚmieciarka.MonoGameView
stepN = 0; stepN = 0;
var dfs = new BFS(collector,grid); var dfs = new DFS(collector,grid);
//steps = dfs.BestPath(Content, collector, grid); //steps = dfs.BestPath(Content, collector, grid);
new Thread(delegate() { new Thread(delegate() {
var x = dfs.BestPath(Content, collector, grid); var x = dfs.BestPath(Content, collector, grid);