From 8cc3e460f23736ee884501fe1d2373d809237963 Mon Sep 17 00:00:00 2001 From: DariusTFox24 Date: Wed, 1 Dec 2021 21:17:53 +0200 Subject: [PATCH 1/4] Initial interface --- .vscode/launch.json | 3 ++- Program.cs | 58 +++++++++++++++++++++++++++++++++++++++++++-- labyrinth.txt | 5 ++++ labyrinthOUT.txt | 5 ++++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 labyrinth.txt create mode 100644 labyrinthOUT.txt diff --git a/.vscode/launch.json b/.vscode/launch.json index 755b923..d89ba50 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,7 +17,8 @@ "args": [], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", "stopAtEntry": false }, { diff --git a/Program.cs b/Program.cs index 958dd46..af609ef 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,59 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); -Console.WriteLine("this is slow"); +string[] labyrinthIN = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinth.txt"); +string[] labyrinthOUT = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinthOUT.txt"); + +System.Console.WriteLine("The input labyrinth: "); +foreach (string line in labyrinthIN) +{ + FormattedLabRow(line); +} + +System.Console.WriteLine("The output labyrinth: "); +foreach (string line in labyrinthOUT) +{ + FormattedLabRow(line); +} + + +void FormattedLabRow(string line) { + char[] characters = line.ToCharArray(); + foreach (char c in characters) { + switch ( c ) { + case '#': { + Console.BackgroundColor = ConsoleColor.White; + Console.Write(" "); + break; + } + + case ' ': { + Console.BackgroundColor = ConsoleColor.Black; + Console.Write(" "); + break; + } + + case 'S': { + Console.BackgroundColor = ConsoleColor.Green; + Console.Write(" "); + break; + } + + case 'F': { + Console.BackgroundColor = ConsoleColor.Red; + Console.Write(" "); + break; + } + + case 'p': { + Console.BackgroundColor = ConsoleColor.Cyan; + Console.Write(" "); + break; + } + + default: break; + } + } + Console.ResetColor(); + Console.WriteLine(); +} \ No newline at end of file diff --git a/labyrinth.txt b/labyrinth.txt new file mode 100644 index 0000000..0983427 --- /dev/null +++ b/labyrinth.txt @@ -0,0 +1,5 @@ +###S# +# # +## # +# ## +#F### \ No newline at end of file diff --git a/labyrinthOUT.txt b/labyrinthOUT.txt new file mode 100644 index 0000000..a56df2b --- /dev/null +++ b/labyrinthOUT.txt @@ -0,0 +1,5 @@ +###S# +# p# +##pp# +#pp## +#F### \ No newline at end of file From f251002a372463b16f15068dab1e31daff8289fe Mon Sep 17 00:00:00 2001 From: DariusTFox24 Date: Wed, 1 Dec 2021 22:29:43 +0200 Subject: [PATCH 2/4] Display labyrinth attempt #1 --- Program.cs | 72 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/Program.cs b/Program.cs index af609ef..da607eb 100644 --- a/Program.cs +++ b/Program.cs @@ -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[] labyrinthOUT = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinthOUT.txt"); +string[] labyrinthIN = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinthOUT.txt"); System.Console.WriteLine("The input labyrinth: "); @@ -10,11 +9,56 @@ foreach (string line in labyrinthIN) FormattedLabRow(line); } -System.Console.WriteLine("The output labyrinth: "); -foreach (string line in labyrinthOUT) -{ - FormattedLabRow(line); -} +var algoBoard = new IdaStar.WorkingBoard(labyrinthIN.Select((row) => row.ToList()).ToList()); +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 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"); break; } case 'F': { Console.BackgroundColor = ConsoleColor.Red; - Console.Write(" "); + Console.Write("[ ]"); break; } case 'p': { - Console.BackgroundColor = ConsoleColor.Cyan; - Console.Write(" "); + Console.BackgroundColor = ConsoleColor.Blue; + Console.Write(" • "); break; } From 63e18009c76034b353e6f17214591a053fea06e3 Mon Sep 17 00:00:00 2001 From: DariusTFox24 Date: Wed, 1 Dec 2021 23:45:08 +0200 Subject: [PATCH 3/4] Working labyrinth display --- Program.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Program.cs b/Program.cs index da607eb..f6dfe88 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,6 @@ using IdaStar; -string[] labyrinthIN = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinthOUT.txt"); +string[] labyrinthIN = System.IO.File.ReadAllLines(@"C:\UNI\AI\IDAstar\labyrinth.txt"); System.Console.WriteLine("The input labyrinth: "); @@ -19,17 +19,18 @@ algoBoard.AlgorithmStep += (_) => { if(done){ System.Console.WriteLine("The solved labyrinth is:"); }else if(step/2 == 0) { - System.Console.WriteLine("Computing [• ]"); + System.Console.WriteLine("Computing [· ]"); }else { - System.Console.WriteLine("Computing [ •]"); + System.Console.WriteLine("Computing [ ·]"); } //top border Console.BackgroundColor = border; for (var i=0; i { //left border Console.BackgroundColor = border; - Console.Write("|||"); + Console.Write(" "); Console.ResetColor(); //labyrinth line @@ -46,16 +47,19 @@ algoBoard.AlgorithmStep += (_) => { //right border Console.BackgroundColor = border; - Console.Write("|||"); + Console.Write(" "); Console.ResetColor(); + + Console.WriteLine(); } //bottom border Console.BackgroundColor = border; for (var i=0; i"); + Console.Write("<·>"); break; } @@ -91,7 +95,7 @@ void FormattedLabRow(string line) { case 'p': { Console.BackgroundColor = ConsoleColor.Blue; - Console.Write(" • "); + Console.Write(" · "); break; } @@ -99,5 +103,4 @@ void FormattedLabRow(string line) { } } Console.ResetColor(); - Console.WriteLine(); } \ No newline at end of file From 1c3f99d86d57c9ffc0f61c375d51fc842e7b35b7 Mon Sep 17 00:00:00 2001 From: DariusTFox24 Date: Wed, 1 Dec 2021 23:53:02 +0200 Subject: [PATCH 4/4] Updated labyrinth --- labyrinth.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/labyrinth.txt b/labyrinth.txt index 0983427..46414a8 100644 --- a/labyrinth.txt +++ b/labyrinth.txt @@ -1,5 +1,7 @@ -###S# -# # -## # -# ## -#F### \ No newline at end of file +########## +#S # # F +### # ## # +# # # +## # # +# # ### # +########## \ No newline at end of file