parser
This commit is contained in:
parent
f6e30ed848
commit
c3c0b57036
@ -6,12 +6,15 @@ using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using System.Threading;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGameView.DataModels.Models;
|
||||
|
||||
namespace MonoGameView.Algorithms
|
||||
@ -55,23 +58,183 @@ namespace MonoGameView.Algorithms
|
||||
|
||||
var dataToLog = Jazda(r.Item1, CopyGrid(grid), (GarbageCollector) collector.Clone()).ToList();
|
||||
|
||||
|
||||
/*Oznaczenia
|
||||
*0 - trawa, nie do poruszania
|
||||
*10 - droga po której można się poruszać
|
||||
*11 - droga po której nie można się poruszać
|
||||
*20 - dom z którego można wziąć śmieci
|
||||
*21 - dom z którego nie można wziąć śmieci w tym momencie
|
||||
*22 - dom pusty, bez śmieci
|
||||
*30 - wysypisko szkła
|
||||
*31 - wysypisko plastików i metali
|
||||
*32 - wysypisko odpadów organicznych
|
||||
*33 - wysypisko papieru
|
||||
*40 - ruch w górę
|
||||
*41 - ruch w prawo
|
||||
*42 - ruch w dół
|
||||
*43 - ruch w lewo
|
||||
*50 - zbierz śmieci
|
||||
*51 - wyrzuć śmieci
|
||||
*/
|
||||
|
||||
Console.WriteLine($"Counts : {count}");
|
||||
if (r == null) return new Tuple<List<IStep>, int, List<ICloneable[,]>>(new List<IStep>(), 0, new List<ICloneable[,]>());
|
||||
return r;
|
||||
using (StreamWriter writer = new StreamWriter("chuj.txt"))
|
||||
{
|
||||
foreach (var item in dataToLog)
|
||||
{
|
||||
|
||||
string line = "";
|
||||
if (item.Key is MoveStep)
|
||||
{
|
||||
MoveStep move = (item.Key as MoveStep);
|
||||
String[,] mygrid = item.Value;
|
||||
switch (move.GetDirection().ToString())
|
||||
{
|
||||
case "Up":
|
||||
line += "40";
|
||||
break;
|
||||
case "Right":
|
||||
line += "41";
|
||||
break;
|
||||
case "Down":
|
||||
line += "42";
|
||||
break;
|
||||
case "Left":
|
||||
line += "43";
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (string field in mygrid)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case "grass":
|
||||
line += "," + "0";
|
||||
break;
|
||||
case "road1":
|
||||
line += "," + "10";
|
||||
break;
|
||||
case "road2":
|
||||
line += "," + "11";
|
||||
break;
|
||||
case "house":
|
||||
line += "," + "20";
|
||||
break;
|
||||
case "emptyHouse":
|
||||
line += "," + "22";
|
||||
break;
|
||||
case "Glass":
|
||||
line += "," + "30";
|
||||
break;
|
||||
case "PlasticMetal":
|
||||
line += "," + "31";
|
||||
break;
|
||||
case "Organic":
|
||||
line += "," + "32";
|
||||
break;
|
||||
case "Paper":
|
||||
line += "," + "33";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.Key is CollectStep)
|
||||
{
|
||||
CollectStep collect = (item.Key as CollectStep);
|
||||
String[,] mygrid = item.Value;
|
||||
line += "50";
|
||||
foreach (string field in mygrid)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case "grass":
|
||||
line += "," + "0";
|
||||
break;
|
||||
case "road1":
|
||||
line += "," + "10";
|
||||
break;
|
||||
case "road2":
|
||||
line += "," + "11";
|
||||
break;
|
||||
case "house":
|
||||
line += "," + "20";
|
||||
break;
|
||||
case "emptyHouse":
|
||||
line += "," + "22";
|
||||
break;
|
||||
case "Glass":
|
||||
line += "," + "30";
|
||||
break;
|
||||
case "PlasticMetal":
|
||||
line += "," + "31";
|
||||
break;
|
||||
case "Organic":
|
||||
line += "," + "32";
|
||||
break;
|
||||
case "Paper":
|
||||
line += "," + "33";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SpillStep spill = (item.Key as SpillStep);
|
||||
String[,] mygrid = item.Value;
|
||||
line += "51";
|
||||
foreach (string field in mygrid)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case "grass":
|
||||
line += "," + "0";
|
||||
break;
|
||||
case "road1":
|
||||
line += "," + "10";
|
||||
break;
|
||||
case "road2":
|
||||
line += "," + "11";
|
||||
break;
|
||||
case "house":
|
||||
line += "," + "20";
|
||||
break;
|
||||
case "emptyHouse":
|
||||
line += "," + "22";
|
||||
break;
|
||||
case "Glass":
|
||||
line += "," + "30";
|
||||
break;
|
||||
case "PlasticMetal":
|
||||
line += "," + "31";
|
||||
break;
|
||||
case "Organic":
|
||||
line += "," + "32";
|
||||
break;
|
||||
case "Paper":
|
||||
line += "," + "33";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
writer.WriteLine(line);
|
||||
}
|
||||
}
|
||||
if (r == null)
|
||||
return new Tuple<List<IStep>, int, List<ICloneable[,]>>(new List<IStep>(), 0,
|
||||
new List<ICloneable[,]>());
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<KeyValuePair<IStep, ICloneable[,]>> Jazda(List<IStep> steps, ICloneable[,] grid, GarbageCollector collector)
|
||||
public IEnumerable<KeyValuePair<IStep, String[,]>> Jazda(List<IStep> steps, ICloneable[,] grid, GarbageCollector collector)
|
||||
{
|
||||
|
||||
|
||||
for (int i =0;i<steps.Count();i++)
|
||||
{
|
||||
|
||||
var minGrid = new ICloneable[5, 5];
|
||||
var minGrid = new String[5, 5];
|
||||
|
||||
for (int x = collector.Coords.X-2; x <= collector.Coords.X+2;x++)
|
||||
{
|
||||
@ -97,8 +260,7 @@ namespace MonoGameView.Algorithms
|
||||
}
|
||||
}
|
||||
}
|
||||
yield return new KeyValuePair<IStep, ICloneable[,]>(steps[i], minGrid);
|
||||
|
||||
yield return new KeyValuePair<IStep, String[,]>(steps[i], minGrid);
|
||||
|
||||
|
||||
|
||||
|
@ -22,6 +22,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
|
||||
private GarbageType _typeOfGarbage;
|
||||
|
||||
public GarbageType GetTypeOfGarbage()
|
||||
{
|
||||
return _typeOfGarbage;
|
||||
}
|
||||
public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid)
|
||||
{
|
||||
|
||||
|
@ -20,6 +20,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
private Direction _direction;
|
||||
private IGarbageCollector _garbageCollector;
|
||||
|
||||
public Direction GetDirection()
|
||||
{
|
||||
return _direction;
|
||||
}
|
||||
public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid)
|
||||
{
|
||||
if(grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] is Road1)
|
||||
|
@ -20,6 +20,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
|
||||
private GarbageType _typeOfGarbage;
|
||||
|
||||
public GarbageType GetTypeOfGarbage()
|
||||
{
|
||||
return _typeOfGarbage;
|
||||
}
|
||||
public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid)
|
||||
{
|
||||
var _dump = (ADump)grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y];
|
||||
|
Loading…
Reference in New Issue
Block a user