mapy 1-4
This commit is contained in:
parent
1215d9549e
commit
627a9c7fc0
@ -27,7 +27,7 @@ namespace MonoGameView.Algorithms
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
public List<Coords> Houses { get; set; }
|
public List<Coords> Houses { get; set; }
|
||||||
|
|
||||||
public List<IStep> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
public KeyValuePair<List<IStep>,int> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
||||||
{
|
{
|
||||||
Houses = new List<Coords>();
|
Houses = new List<Coords>();
|
||||||
for (int x = 0; x < grid.GetLength(0); x++)
|
for (int x = 0; x < grid.GetLength(0); x++)
|
||||||
@ -44,9 +44,9 @@ namespace MonoGameView.Algorithms
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var r = SearchBfs(content, collector, grid, 0).Key;
|
var r = SearchBfs(content, collector, grid, 0);
|
||||||
Console.WriteLine($"Counts : {count}");
|
Console.WriteLine($"Counts : {count}");
|
||||||
if (r == null) return new List<IStep>();
|
if (r.Key == null) return new KeyValuePair<List<IStep>,int>(new List<IStep>(), 0);
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -138,15 +138,17 @@ namespace MonoGameView.Algorithms
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine(count);
|
//Console.WriteLine(count);
|
||||||
Console.WriteLine(nodes.Count);
|
//Console.WriteLine(nodes.Count);
|
||||||
count++;
|
|
||||||
//var nodes2 = new List<Tuple<List<IStep>, GarbageCollector, ICloneable[,]>>();
|
//var nodes2 = new List<Tuple<List<IStep>, GarbageCollector, ICloneable[,]>>();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
|
|
||||||
var item = nodes.Dequeue();
|
var item = nodes.Dequeue();
|
||||||
//Thread.Sleep(100);
|
//Thread.Sleep(100);
|
||||||
this.Collector.Coords = item.Item2.Coords;
|
/*this.Collector.Coords = item.Item2.Coords;
|
||||||
this.Collector.TrashContainers = item.Item2.TrashContainers;
|
this.Collector.TrashContainers = item.Item2.TrashContainers;
|
||||||
for (int x = 0; x < item.Item3.GetLength(0); x++)
|
for (int x = 0; x < item.Item3.GetLength(0); x++)
|
||||||
{
|
{
|
||||||
@ -154,14 +156,15 @@ namespace MonoGameView.Algorithms
|
|||||||
{
|
{
|
||||||
this.Grid[x, y] = item.Item3[x, 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))
|
if (Houses.All(c => (item.Item3[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0))
|
||||||
&&
|
&&
|
||||||
item.Item2.TrashContainers.All(i => i.FillPercent == 0.0)
|
item.Item2.TrashContainers.All(i => i.FillPercent == 0.0)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new KeyValuePair<List<IStep>, int>(item.Item1, length);
|
Console.WriteLine(count);
|
||||||
|
return new KeyValuePair<List<IStep>, int>(item.Item1, count);
|
||||||
}
|
}
|
||||||
if (true)//item.Item2.Counter <= 12)
|
if (true)//item.Item2.Counter <= 12)
|
||||||
{
|
{
|
||||||
|
@ -24,11 +24,12 @@ namespace MonoGameView.Algorithms
|
|||||||
this.Collector = collector;
|
this.Collector = collector;
|
||||||
this.Grid = grid;
|
this.Grid = grid;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count;
|
||||||
public List<Coords> Houses { get; set; }
|
public List<Coords> Houses { get; set; }
|
||||||
public List<Coords> Dumps { get; set; }
|
public List<Coords> Dumps { get; set; }
|
||||||
public List<IStep> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
public List<IStep> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
||||||
{
|
{
|
||||||
|
|
||||||
Houses = new List<Coords>();
|
Houses = new List<Coords>();
|
||||||
Dumps = new List<Coords>();
|
Dumps = new List<Coords>();
|
||||||
for (int x = 0; x < grid.GetLength(0); x++)
|
for (int x = 0; x < grid.GetLength(0); x++)
|
||||||
@ -48,7 +49,7 @@ namespace MonoGameView.Algorithms
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var r = SearchBfs(content, collector, grid, 0).Key;
|
var r = SearchBestFirst(content, collector, grid, 0).Key;
|
||||||
Console.WriteLine($"Counts : {count}");
|
Console.WriteLine($"Counts : {count}");
|
||||||
if (r == null) return new List<IStep>();
|
if (r == null) return new List<IStep>();
|
||||||
return r;
|
return r;
|
||||||
@ -182,17 +183,17 @@ namespace MonoGameView.Algorithms
|
|||||||
var closestDump = (closestDumps.Any()) ? closestDumps.Min(b => Math.Pow(t.Item2.Coords.X - b.Coords.X, 2) + Math.Pow(t.Item2.Coords.Y - b.Coords.Y, 2)) : 0.0;
|
var closestDump = (closestDumps.Any()) ? closestDumps.Min(b => Math.Pow(t.Item2.Coords.X - b.Coords.X, 2) + Math.Pow(t.Item2.Coords.Y - b.Coords.Y, 2)) : 0.0;
|
||||||
|
|
||||||
|
|
||||||
return (int) (p1 * 1000 + 10*closestHouse + closestDump);
|
return (int) (p1 * 1000 + 100*closestHouse + closestDump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KeyValuePair<List<IStep>, int> SearchBfs(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length)
|
KeyValuePair<List<IStep>, int> SearchBestFirst(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Thread.Sleep(1);
|
//Thread.Sleep(1);
|
||||||
int count = 0;
|
count = 0;
|
||||||
|
|
||||||
var nodes = new PriorityQueue<Tuple<List<IStep>, GarbageCollector, ICloneable[,]>>();
|
var nodes = new PriorityQueue<Tuple<List<IStep>, GarbageCollector, ICloneable[,]>>();
|
||||||
|
|
||||||
@ -201,11 +202,12 @@ namespace MonoGameView.Algorithms
|
|||||||
nodes.Enqueue(f,Priority(f));
|
nodes.Enqueue(f,Priority(f));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
var p = nodes.Dequeue();
|
var p = nodes.Dequeue();
|
||||||
var item = p.Key;
|
var item = p.Key;
|
||||||
var priority = p.Value;
|
var priority = p.Value;
|
||||||
|
|
||||||
Thread.Sleep(100);
|
/*Thread.Sleep(10);
|
||||||
this.Collector.Coords = item.Item2.Coords;
|
this.Collector.Coords = item.Item2.Coords;
|
||||||
this.Collector.TrashContainers = item.Item2.TrashContainers;
|
this.Collector.TrashContainers = item.Item2.TrashContainers;
|
||||||
for (int x = 0; x < item.Item3.GetLength(0); x++)
|
for (int x = 0; x < item.Item3.GetLength(0); x++)
|
||||||
@ -214,7 +216,7 @@ namespace MonoGameView.Algorithms
|
|||||||
{
|
{
|
||||||
this.Grid[x, y] = item.Item3[x, 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))
|
if (Houses.All(c => (item.Item3[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0))
|
||||||
&&
|
&&
|
||||||
|
@ -28,7 +28,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
public List<Coords> Houses { get; set; }
|
public List<Coords> Houses { get; set; }
|
||||||
|
|
||||||
public List<IStep> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
public KeyValuePair<List<IStep>,int> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
||||||
{
|
{
|
||||||
Houses = new List<Coords>();
|
Houses = new List<Coords>();
|
||||||
for (int x = 0; x < grid.GetLength(0); x++)
|
for (int x = 0; x < grid.GetLength(0); x++)
|
||||||
@ -47,8 +47,8 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
|
|
||||||
var r=Search(content, collector, grid, 0).Key;
|
var r=Search(content, collector, grid, 0).Key;
|
||||||
Console.WriteLine($"Counts : {count}");
|
Console.WriteLine($"Counts : {count}");
|
||||||
if (r == null) return new List<IStep>();
|
if (r == null) return new KeyValuePair<List<IStep>,int>(new List<IStep>(),0);
|
||||||
return r;
|
return new KeyValuePair<List<IStep>, int>(r,count);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +130,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(10);
|
||||||
this.Collector.Coords = collector.Coords;
|
/*this.Collector.Coords = collector.Coords;
|
||||||
this.Collector.TrashContainers = collector.TrashContainers;
|
this.Collector.TrashContainers = collector.TrashContainers;
|
||||||
|
|
||||||
for (int x = 0; x < grid.GetLength(0); x++)
|
for (int x = 0; x < grid.GetLength(0); x++)
|
||||||
@ -142,11 +142,11 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
this.Grid[x, y] = (ICloneable) grid[x, y].Clone();
|
this.Grid[x, y] = (ICloneable) grid[x, y].Clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Console.WriteLine(collector.HouseCounter);
|
||||||
|
|
||||||
Console.WriteLine(collector.HouseCounter);
|
if (collector.Counter> 1000 || length > 10000)
|
||||||
|
|
||||||
if (collector.Counter> 100 || length > 1000)
|
|
||||||
return new KeyValuePair<List<IStep>, int>(null,length);
|
return new KeyValuePair<List<IStep>, int>(null,length);
|
||||||
count++;
|
count++;
|
||||||
if (Houses.All(c => (grid[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0))
|
if (Houses.All(c => (grid[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0))
|
||||||
|
@ -6,6 +6,6 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IDrawables : ICloneable
|
public interface IDrawables : ICloneable
|
||||||
{
|
{
|
||||||
void Draw(SpriteBatch spriteBatch, int size);
|
void Draw(SpriteBatch spriteBatch, int size, int width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size, int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
|
||||||
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()+"Bar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, (int)Math.Round(FillPercent * 500) / size, 50 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()+"Bar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, (int)Math.Round(FillPercent * width) / size, 50 / size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object Clone()
|
public override object Clone()
|
||||||
|
@ -21,9 +21,9 @@ namespace MonoGameView.DataModels.Models
|
|||||||
Coords = coords;
|
Coords = coords;
|
||||||
TrashCans = new List<ATrashCan>();
|
TrashCans = new List<ATrashCan>();
|
||||||
}
|
}
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size, int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Clone()
|
public object Clone()
|
||||||
|
@ -20,9 +20,9 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch,int size)
|
public void Draw(SpriteBatch batch,int size,int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("collector"), new Rectangle(Coords.X*500/size, Coords.Y*500/size, 500/size, 500/size), Color.White);
|
batch.Draw(ImageContainer.GetImage("collector"), new Rectangle(Coords.X*width/size, Coords.Y*width/size, width/size, width/size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ namespace MonoGameView.DataModels.Models
|
|||||||
return new Grass((Coords)Coords.Clone());
|
return new Grass((Coords)Coords.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size, int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("grass"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("grass"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,24 +23,24 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
Coords = coords;
|
Coords = coords;
|
||||||
TrashCans = trashCans.Select(x=>(x as ATrashCan)).ToList();
|
TrashCans = trashCans.Select(x=>(x as ATrashCan)).ToList();
|
||||||
}
|
}
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size,int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("house"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("house"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
|
||||||
foreach (TrashCan can in TrashCans)
|
foreach (TrashCan can in TrashCans)
|
||||||
{
|
{
|
||||||
switch (can.Garbage.TypeOfGarbage.GarbageType)
|
switch (can.Garbage.TypeOfGarbage.GarbageType)
|
||||||
{
|
{
|
||||||
case GarbageType.Glass:
|
case GarbageType.Glass:
|
||||||
batch.Draw(ImageContainer.GetImage("GlassBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("GlassBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + width/200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
|
||||||
break;
|
break;
|
||||||
case GarbageType.Paper:
|
case GarbageType.Paper:
|
||||||
batch.Draw(ImageContainer.GetImage("PaperBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 5, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("PaperBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + 2*width / 200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
|
||||||
break;
|
break;
|
||||||
case GarbageType.PlasticMetal:
|
case GarbageType.PlasticMetal:
|
||||||
batch.Draw(ImageContainer.GetImage("PlasticMetalBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 10, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("PlasticMetalBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + 3*width / 200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
|
||||||
break;
|
break;
|
||||||
case GarbageType.Organic:
|
case GarbageType.Organic:
|
||||||
batch.Draw(ImageContainer.GetImage("OrganicBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 15, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("OrganicBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + 4*width / 200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
return new Road1((Coords)Coords.Clone());
|
return new Road1((Coords)Coords.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size, int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("road1"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("road1"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
return new Road2((Coords)Coords.Clone());
|
return new Road2((Coords)Coords.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size, int width)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
MapLoader mapLoader = new MapLoader();
|
MapLoader mapLoader = new MapLoader();
|
||||||
Vector2 roadPos;
|
Vector2 roadPos;
|
||||||
float timer;
|
float timer;
|
||||||
const float TIMER = 0.001f;
|
const float TIMER = 0.1f;
|
||||||
int stepN;
|
int stepN;
|
||||||
List<IStep> steps;
|
List<IStep> steps;
|
||||||
GarbageCollector collector;
|
GarbageCollector collector;
|
||||||
@ -45,8 +45,8 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
{
|
{
|
||||||
graphics = new GraphicsDeviceManager(this);
|
graphics = new GraphicsDeviceManager(this);
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
graphics.PreferredBackBufferWidth =700;
|
graphics.PreferredBackBufferWidth =1400;
|
||||||
graphics.PreferredBackBufferHeight =500;
|
graphics.PreferredBackBufferHeight =1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,29 +62,29 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
|
|
||||||
ImageContainer.InitContainer(Content);
|
ImageContainer.InitContainer(Content);
|
||||||
// TODO: Add your initialization logic here
|
// TODO: Add your initialization logic here
|
||||||
timer = 0f;
|
timer = 1f;
|
||||||
|
|
||||||
mapLoader.Load(out size,out grid,"mapa2.xml");
|
mapLoader.Load(out size,out grid,"mapa4.xml");
|
||||||
var containers = new List<GarbageCollectorContainer>()
|
var containers = new List<GarbageCollectorContainer>()
|
||||||
{
|
{
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.Glass,1),
|
new TypeOfGarbage(GarbageType.Glass,1),
|
||||||
10000,
|
1000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
||||||
),
|
),
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.Paper,1),
|
new TypeOfGarbage(GarbageType.Paper,1),
|
||||||
10000,
|
1000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Paper,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Paper,1),0)
|
||||||
),
|
),
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.Organic,1),
|
new TypeOfGarbage(GarbageType.Organic,1),
|
||||||
10000,
|
1000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Organic,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Organic,1),0)
|
||||||
),
|
),
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.PlasticMetal,1),
|
new TypeOfGarbage(GarbageType.PlasticMetal,1),
|
||||||
10000,
|
1000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.PlasticMetal,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.PlasticMetal,1),0)
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -94,11 +94,14 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
|
|
||||||
stepN = 0;
|
stepN = 0;
|
||||||
var dfs = new DFS(collector,grid);
|
var dfs = new DFS(collector,grid);
|
||||||
//steps = dfs.BestPath(Content, collector, grid);
|
var r = dfs.BestPath(Content, collector, grid);
|
||||||
new Thread(delegate() {
|
steps = r.Key;
|
||||||
var x = dfs.BestPath(Content, collector, grid);
|
Console.WriteLine(r);
|
||||||
|
//displayer.Add("Count", r.Value.ToString());
|
||||||
|
//new Thread(delegate() {
|
||||||
|
// var x = dfs.BestPath(Content, collector, grid);
|
||||||
|
|
||||||
}).Start();
|
//}).Start();
|
||||||
|
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
}
|
}
|
||||||
@ -112,6 +115,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
// Create a new SpriteBatch, which can be used to draw textures.
|
// Create a new SpriteBatch, which can be used to draw textures.
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
font = Content.Load<SpriteFont>("arial");
|
font = Content.Load<SpriteFont>("arial");
|
||||||
|
|
||||||
// TODO: use this.Content to load your game content here
|
// TODO: use this.Content to load your game content here
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +138,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
{
|
{
|
||||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||||
Exit();
|
Exit();
|
||||||
/*
|
|
||||||
var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
timer -= elapsed;
|
timer -= elapsed;
|
||||||
if (timer<0)
|
if (timer<0)
|
||||||
@ -146,7 +150,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
steps.RemoveAt(0);
|
steps.RemoveAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// TODO: Add your update logic here
|
// TODO: Add your update logic here
|
||||||
var barsDictionary = new Dictionary<string, int>();
|
var barsDictionary = new Dictionary<string, int>();
|
||||||
var collectorDictionary = new Dictionary<string, string>
|
var collectorDictionary = new Dictionary<string, string>
|
||||||
@ -177,10 +181,10 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
{
|
{
|
||||||
for (int y = 0; y < size; y++)
|
for (int y = 0; y < size; y++)
|
||||||
{
|
{
|
||||||
grid[x, y].Draw(spriteBatch, size);
|
grid[x, y].Draw(spriteBatch, size, graphics.PreferredBackBufferHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
collector.Draw(spriteBatch, size);
|
collector.Draw(spriteBatch, size, graphics.PreferredBackBufferHeight);
|
||||||
Display(displayer.info, displayer.barsPercent);
|
Display(displayer.info, displayer.barsPercent);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
@ -194,23 +198,22 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
public void Display(Dictionary<string, string> info, Dictionary<string,int> barInfo)
|
public void Display(Dictionary<string, string> info, Dictionary<string,int> barInfo)
|
||||||
{
|
{
|
||||||
int x = 510;
|
int width = graphics.PreferredBackBufferHeight;
|
||||||
int y = 10;
|
int x = width + width/50;
|
||||||
|
int y = width/50;
|
||||||
foreach (KeyValuePair<string, string> item in info)
|
foreach (KeyValuePair<string, string> item in info)
|
||||||
{
|
{
|
||||||
spriteBatch.DrawString(font, item.Key, new Vector2(x, y), Color.Black);
|
if (barInfo.ContainsKey(item.Key))
|
||||||
y += 15;
|
|
||||||
spriteBatch.DrawString(font, item.Value, new Vector2(x, y), Color.White);
|
|
||||||
y += 30;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var bar = barInfo[item.Key];
|
var bar = barInfo[item.Key];
|
||||||
spriteBatch.Draw(ImageContainer.GetImage(item.Key+"Bar"), new Rectangle(x, y, bar * 40, 10), Color.White);
|
spriteBatch.Draw(ImageContainer.GetImage(item.Key + "Bar"), new Rectangle(x, y, bar * width / 500, width / 50), Color.White);
|
||||||
y += 50;
|
y += width / 50;
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
spriteBatch.DrawString(font, item.Key, new Vector2(x, y), Color.Black);
|
||||||
|
y += width*2/100;
|
||||||
|
spriteBatch.DrawString(font, item.Value, new Vector2(x, y), Color.White);
|
||||||
|
y += width*3/50;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
Trunk/mapa1.xml
Normal file
1
Trunk/mapa1.xml
Normal file
File diff suppressed because one or more lines are too long
1
Trunk/mapa2.xml
Normal file
1
Trunk/mapa2.xml
Normal file
File diff suppressed because one or more lines are too long
1
Trunk/mapa3.xml
Normal file
1
Trunk/mapa3.xml
Normal file
File diff suppressed because one or more lines are too long
12164
Trunk/mapa4.xml
Normal file
12164
Trunk/mapa4.xml
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user