-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Sofken-natori/add-arrange-line-method
Add arrange line method
- Loading branch information
Showing
17 changed files
with
2,814 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"Procon" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
using EntryPoint; | ||
using System; | ||
using _2024ProconTemporary.ReadableData; | ||
using _2024ProconTemporary.Com; | ||
using _2024ProconTemporary; | ||
using System.Linq; | ||
|
||
|
||
namespace _2024ProconTemporary.CommandLine.Commands | ||
{ | ||
public class BootCommandClient : BaseCliArguments | ||
{ | ||
public BootCommandClient() : base("Initialize Command") { } | ||
|
||
[OptionParameter(ShortName: 'v', LongName: "view")] | ||
[Help("問題データを表示します")] | ||
public bool isView { get; set; } | ||
|
||
[OptionParameter(ShortName: 'm', LongName: "manual")] | ||
[Help("手動で回答を作成するモードに移行します")] | ||
public bool isManual { get; set; } | ||
} | ||
|
||
public class BootCommand | ||
{ | ||
public void Handle(BootCommandClient args) | ||
{ | ||
Console.WriteLine("Booting..."); | ||
// 問題データを取得する | ||
Console.WriteLine("Getting Problem Data..."); | ||
HttpClient client = Networking.CreateClient(); | ||
var problemData = Networking.GetProblemData(client); | ||
|
||
if (problemData == null) | ||
{ | ||
Console.WriteLine("ERROR: ProblemData Download Failed!"); | ||
Console.WriteLine("Please check your network connection and try again."); | ||
return; | ||
} | ||
Console.WriteLine("Done!"); | ||
|
||
Console.WriteLine("Converting Problem Data..."); | ||
// 問題データ、回答データをstringの配列からintの2次元配列に変換する | ||
ReadableProblemData convertedProblemData = new ReadableProblemData(problemData); | ||
Console.WriteLine("Done!"); | ||
Console.WriteLine("View Problem Data:"); | ||
convertedProblemData.Print(); | ||
// 問題データを表示する | ||
if (args.isView) | ||
{ | ||
Console.WriteLine("View Problem Data:"); | ||
convertedProblemData.Print(); | ||
} | ||
|
||
AnswerData answerData = Answer.Create(); | ||
|
||
// 手動で回答を作成するモードに移行する | ||
if (args.isManual) | ||
{ | ||
Console.WriteLine("Manual Mode"); | ||
Console.WriteLine("Please input answer."); | ||
ManualMode(problemData); | ||
} | ||
|
||
else | ||
{ | ||
// 自動回答モードに移行する | ||
Console.WriteLine("Automatic Mode"); | ||
Console.WriteLine("Calculating Answer..."); | ||
// ここで問題データをMainAlgorithmに渡して、回答を計算する(引数はReadableProblemData型) | ||
// Mainalgorithm.MatchCalculate(); | ||
|
||
Console.WriteLine("Done!"); | ||
|
||
// 回答結果を表示する(間違っている場所、かかった手数など) 未実装 | ||
|
||
|
||
|
||
// これで提出するか聞く | ||
Console.WriteLine("Do you want to submit this answer? (Y/n)"); | ||
string input = Console.ReadLine() ?? ""; | ||
|
||
if (input == "N" || input == "n") | ||
{ | ||
// 手動で回答を作成するモードに移行する | ||
Console.WriteLine("transit to Manual Mode"); | ||
answerData = ManualMode(problemData); | ||
} | ||
|
||
// 回答を提出する | ||
Console.WriteLine("Submitting Answer..."); | ||
Networking.SendAnswerData(client, answerData); | ||
Console.WriteLine("Done!"); | ||
|
||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// 手動で回答を作成するモードに移行する 未実装 | ||
/// </summary> | ||
/// <param name="problemData">使用する問題データ</param> | ||
/// <returns></returns> | ||
AnswerData ManualMode(ProblemData problemData) | ||
{ | ||
AnswerData answerData = Answer.Create(); | ||
Console.WriteLine("Manual Mode"); | ||
Console.WriteLine("Please input answer."); | ||
|
||
// キー入力を受付、回答を作成する | ||
while (true) | ||
{ | ||
Console.WriteLine("Please press key..."); | ||
|
||
ConsoleKeyInfo key = Console.ReadKey(); | ||
|
||
if (key.Key == ConsoleKey.Escape) | ||
{ | ||
// 終了 | ||
Console.WriteLine("Exit Manual Mode"); | ||
break; | ||
} | ||
|
||
else if (key.Key == ConsoleKey.H) | ||
{ | ||
// ヘルプを表示 | ||
Console.WriteLine("Help"); | ||
} | ||
|
||
else if (key.Key == ConsoleKey.Enter) | ||
{ | ||
|
||
} | ||
|
||
} | ||
return answerData; | ||
|
||
} | ||
|
||
void CompareAnswers(ReadableProblemData problemData, ReadableProblemData answerData) | ||
{ | ||
|
||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using EntryPoint; | ||
using System; | ||
using _2024ProconTemporary.CommandLine.Commands; | ||
using _2024ProconTemporary.Base; | ||
using _2024ProconTemporary.Com; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
class BootProgram | ||
{ | ||
|
||
// static void Main(string[] args) | ||
// { | ||
// Cli.Execute<CommandClient>(args); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using EntryPoint; | ||
using _2024ProconTemporary.CommandLine.Commands; | ||
|
||
|
||
namespace _2024ProconTemporary.Base | ||
{ | ||
public class CommandClient : BaseCliCommands | ||
{ | ||
[DefaultCommand] | ||
[Command("Boot")] | ||
[Help("受け取った問題を解くコマンド")] | ||
public void Boot(string[] args) | ||
{ | ||
var options = Cli.Parse<BootCommandClient>(args); | ||
var command = new BootCommand(); | ||
command.Handle(options); | ||
} | ||
|
||
|
||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
2024ProconTemporary/Command-Line/Convert-Data-Class/ReadableProblemData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System; | ||
using _2024ProconTemporary.Com; | ||
using System.Linq; | ||
|
||
namespace _2024ProconTemporary.ReadableData | ||
{ | ||
public class ReadableProblemData | ||
{ | ||
public ReadableBoardData Board { get; set; } | ||
public ReadableGeneralData General { get; set; } | ||
|
||
public ReadableProblemData(ProblemData problemData) | ||
{ | ||
Board = new ReadableBoardData(problemData.Board.Width, problemData.Board.Height, problemData.Board.Start, problemData.Board.Goal); | ||
General = new ReadableGeneralData(problemData.General.N, problemData.General.Patterns.Select(p => new ReadableGeneralData.ReadablePatternData(p.P, p.Width, p.Height, p.Cells)).ToList()); | ||
} | ||
|
||
public void Print() | ||
{ | ||
Console.WriteLine("Board Data:"); | ||
Console.WriteLine($"Width: {Board.Width}"); | ||
Console.WriteLine($"Height: {Board.Height}"); | ||
Console.WriteLine("Start:"); | ||
foreach (var s in Board.Start) | ||
{ | ||
Console.WriteLine(string.Join(" ", s)); | ||
} | ||
Console.WriteLine("Goal:"); | ||
foreach (var g in Board.Goal) | ||
{ | ||
Console.WriteLine(string.Join(" ", g)); | ||
} | ||
|
||
Console.WriteLine("General Data:"); | ||
Console.WriteLine($"N: {General.N}"); | ||
Console.WriteLine("Patterns:"); | ||
foreach (var p in General.Patterns) | ||
{ | ||
Console.WriteLine($"P: {p.P}"); | ||
Console.WriteLine($"Width: {p.Width}"); | ||
Console.WriteLine($"Height: {p.Height}"); | ||
Console.WriteLine("Cells:"); | ||
foreach (var c in p.Cells) | ||
{ | ||
Console.WriteLine(string.Join(" ", c)); | ||
} | ||
} | ||
} | ||
|
||
public class ReadableBoardData | ||
{ | ||
public int Width { get; set; } | ||
public int Height { get; set; } | ||
public IList<List<int>> Start { get; set; } | ||
public IList<List<int>> Goal { get; set; } | ||
public ReadableBoardData(int width, int height, IList<string> start, IList<string> goal) | ||
{ | ||
Width = width; | ||
Height = height; | ||
|
||
Start = new List<List<int>>(); | ||
|
||
foreach (var s in start) | ||
{ | ||
var list = new List<int>(); | ||
IEnumerable<char> index = s.ToCharArray(); | ||
foreach (var c in index) | ||
{ | ||
list.Add(c - '0'); | ||
} | ||
Start.Add(list); | ||
} | ||
|
||
Goal = new List<List<int>>(); | ||
|
||
foreach (var g in goal) | ||
{ | ||
var list = new List<int>(); | ||
IEnumerable<char> index = g.ToCharArray(); | ||
foreach (var c in index) | ||
{ | ||
list.Add(c - '0'); | ||
} | ||
Goal.Add(list); | ||
} | ||
} | ||
} | ||
|
||
public class ReadableGeneralData | ||
{ | ||
public int N; | ||
public IList<ReadablePatternData> Patterns { get; set; } | ||
|
||
public ReadableGeneralData(int n, IList<ReadablePatternData> patterns) | ||
{ | ||
N = n; | ||
Patterns = patterns; | ||
} | ||
|
||
public class ReadablePatternData | ||
{ | ||
public int P { get; set; } | ||
public int Width { get; set; } | ||
public int Height { get; set; } | ||
public IList<List<int>> Cells { get; set; } | ||
public ReadablePatternData(int p, int width, int height, IList<string> cells) | ||
{ | ||
P = p; | ||
Width = width; | ||
Height = height; | ||
|
||
Cells = new List<List<int>>(); | ||
foreach (var c in cells) | ||
{ | ||
var list = new List<int>(); | ||
IEnumerable<char> index = c.ToCharArray(); | ||
foreach (var i in index) | ||
{ | ||
list.Add(i - '0'); | ||
} | ||
Cells.Add(list); | ||
} | ||
} | ||
|
||
|
||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.