|
|
@ -1,7 +1,6 @@ |
|
|
|
// See https://aka.ms/new-console-template for more information |
|
|
|
using IdaStar; |
|
|
|
|
|
|
|
|
|
|
|
string[] labyrinthIN = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinth.txt"); |
|
|
|
string[] labyrinthIN = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinthOUT.txt"); |
|
|
|
string[] labyrinthOUT = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinthOUT.txt"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.Console.WriteLine("The input labyrinth: "); |
|
|
|
System.Console.WriteLine("The input labyrinth: "); |
|
|
@ -10,12 +9,57 @@ foreach (string line in labyrinthIN) |
|
|
|
FormattedLabRow(line); |
|
|
|
FormattedLabRow(line); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
System.Console.WriteLine("The output labyrinth: "); |
|
|
|
var algoBoard = new IdaStar.WorkingBoard(labyrinthIN.Select((row) => row.ToList()).ToList()); |
|
|
|
foreach (string line in labyrinthOUT) |
|
|
|
int step = 0; |
|
|
|
|
|
|
|
bool done = false; |
|
|
|
|
|
|
|
ConsoleColor border = ConsoleColor.Magenta; |
|
|
|
|
|
|
|
algoBoard.AlgorithmStep += (_) => { |
|
|
|
|
|
|
|
Console.Clear(); |
|
|
|
|
|
|
|
step++; |
|
|
|
|
|
|
|
if(done){ |
|
|
|
|
|
|
|
System.Console.WriteLine("The solved labyrinth is:"); |
|
|
|
|
|
|
|
}else if(step/2 == 0) { |
|
|
|
|
|
|
|
System.Console.WriteLine("Computing [• ]"); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
System.Console.WriteLine("Computing [ •]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//top border |
|
|
|
|
|
|
|
Console.BackgroundColor = border; |
|
|
|
|
|
|
|
for (var i=0; i<algoBoard.Board[0].Count()+2; i++){ |
|
|
|
|
|
|
|
Console.Write("==="); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Console.ResetColor(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var line in algoBoard.Board) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FormattedLabRow(line); |
|
|
|
var charlist = line.Select((state) => CellStateUtil.ToInput(state)); |
|
|
|
|
|
|
|
var str = string.Join("", charlist); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//left border |
|
|
|
|
|
|
|
Console.BackgroundColor = border; |
|
|
|
|
|
|
|
Console.Write("|||"); |
|
|
|
|
|
|
|
Console.ResetColor(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//labyrinth line |
|
|
|
|
|
|
|
FormattedLabRow(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//right border |
|
|
|
|
|
|
|
Console.BackgroundColor = border; |
|
|
|
|
|
|
|
Console.Write("|||"); |
|
|
|
|
|
|
|
Console.ResetColor(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//bottom border |
|
|
|
|
|
|
|
Console.BackgroundColor = border; |
|
|
|
|
|
|
|
for (var i=0; i<algoBoard.Board[0].Count()+2; i++){ |
|
|
|
|
|
|
|
Console.Write("==="); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Console.ResetColor(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
algoBoard.RunIdaStar(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormattedLabRow(string line) { |
|
|
|
void FormattedLabRow(string line) { |
|
|
|
char[] characters = line.ToCharArray(); |
|
|
|
char[] characters = line.ToCharArray(); |
|
|
@ -35,19 +79,19 @@ void FormattedLabRow(string line) { |
|
|
|
|
|
|
|
|
|
|
|
case 'S': { |
|
|
|
case 'S': { |
|
|
|
Console.BackgroundColor = ConsoleColor.Green; |
|
|
|
Console.BackgroundColor = ConsoleColor.Green; |
|
|
|
Console.Write(" "); |
|
|
|
Console.Write("<•>"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'F': { |
|
|
|
case 'F': { |
|
|
|
Console.BackgroundColor = ConsoleColor.Red; |
|
|
|
Console.BackgroundColor = ConsoleColor.Red; |
|
|
|
Console.Write(" "); |
|
|
|
Console.Write("[ ]"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'p': { |
|
|
|
case 'p': { |
|
|
|
Console.BackgroundColor = ConsoleColor.Cyan; |
|
|
|
Console.BackgroundColor = ConsoleColor.Blue; |
|
|
|
Console.Write(" "); |
|
|
|
Console.Write(" • "); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|