Skip to content

Commit

Permalink
add:列を揃えるためのメソッドを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ignotus404 committed Oct 14, 2024
1 parent 4f25c21 commit 18ae997
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 23 deletions.
2 changes: 1 addition & 1 deletion 2024ProconTemporary/Command-Line/BootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void Handle(BootCommandClient args)
Console.WriteLine("Automatic Mode");
Console.WriteLine("Calculating Answer...");
// ここで問題データをMainAlgorithmに渡して、回答を計算する(引数はReadableProblemData型)
MainAlgorithm.MatchCalculate();
// Mainalgorithm.MatchCalculate();

Console.WriteLine("Done!");

Expand Down
8 changes: 4 additions & 4 deletions 2024ProconTemporary/Command-Line/BootProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class BootProgram
{

static void Main(string[] args)
{
Cli.Execute<CommandClient>(args);
}
// static void Main(string[] args)
// {
// Cli.Execute<CommandClient>(args);
// }
}
107 changes: 95 additions & 12 deletions 2024ProconTemporary/MainAlgorithm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

using _2024ProconTemporary.Com;
using _2024ProconTemporary.ReadableData;
using System;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
Expand All @@ -10,7 +12,7 @@ namespace _2024ProconTemporary

public class Mainalgorithm
{

Case cases = new Case();
Practice practice = new Practice();
Pattern Pattern = new Pattern();
Expand All @@ -35,15 +37,15 @@ public static void Main()
Hyoji(Practice.QuesTes2);
//Practice.QuesTes = QuestionShunting(Practice.QuesTes2,Practice.AnsTes2);
// Console.WriteLine("");
for(int i = 0; i < 1; i++)
for (int i = 0; i < 1; i++)
{
IndexCount(Practice.QuesTes2);
MainTest(Practice.QuesTes2, Practice.AnsTes2, 0);
}


}
public AnswerData Calculation(ProblemData problemData)
public AnswerData Calculation(ProblemData problemData)
{
Pattern.Patterns();
Practice.Practices();
Expand All @@ -58,8 +60,8 @@ public AnswerData Calculation(ProblemData problemData)
}
return new AnswerData
{
N = 0,
Ops = new List<AnswerData.OperationData>()
N = 0,
Ops = new List<AnswerData.OperationData>()
};
}
public static void Hyoji(List<List<int>> Ans)
Expand Down Expand Up @@ -109,7 +111,7 @@ public static List<List<int>> QuestionShunting(List<List<int>> Ques, List<List<i
result[Y].Add(ListWarp(X, Y));
}
}
ZeroCount = WarpValuationCalculation(result, Ans, Practice.pieceX, Practice.pieceY);
ZeroCount = WarpValuationCalculation(result, Ans, Practice.pieceX, Practice.pieceY);
if (ZeroCount > MaxZeroCount)
{
MaxZeroCount = ZeroCount;
Expand Down Expand Up @@ -205,8 +207,8 @@ public static List<List<int>> MainTest(List<List<int>> Ques, List<List<int>> Ans
WantIndex[0].Add(new List<int>());
WantIndex[0][Y] = Search(Ques, Ans, WantIndex[0][Y], 1, Y);
WantIndex[1].Add(new List<int>());
WantIndex[1][Y] = Search(Ques, Ans, WantIndex[1][Y], WantIndex[0][Y].Count + 2, Y);
NextSearch(Ques, Ans, WantIndex, WantIndex[0][Y].Count + WantIndex[1][Y].Count + 2, Y);
WantIndex[1][Y] = Search(Ques, Ans, WantIndex[1][Y], WantIndex[0][Y].Count + 2, Y);
NextSearch(Ques, Ans, WantIndex, WantIndex[0][Y].Count + WantIndex[1][Y].Count + 2, Y);

}

Expand Down Expand Up @@ -267,7 +269,7 @@ public static List<int> NextSearch(List<List<int>> Ques, List<List<int>> Ans, Li
}
break;
}
if(i== 1)
if (i == 1)
{
ques[Y].RemoveAt(QuesNumberIndex);
}
Expand Down Expand Up @@ -307,7 +309,7 @@ public static void EvaluationValue(List<List<int>> Ques, List<List<int>> Ans, Li
}
public static void Check(List<List<int>> Ques, List<List<int>> Ans, List<List<List<int>>> WantTypeIndex)
{

}

public static void Overcalculation(List<List<int>> Ques, List<List<int>> Ans, List<List<List<int>>> WantTypeIndex)
Expand Down Expand Up @@ -374,5 +376,86 @@ public static void IndexCount(List<List<int>> Ques)

}

///<summary>
/// 列ごとを揃えたあとに、行ごとで揃えるために必要な型の種類と抜く座標を返す
///</summary>
public (int, int, int, int) SearchDie(ReadableProblemData problemData, List<List<int>> ques, List<List<int>> ans)
{
int useDieNum = 0;
int cuttingDirection = 0;
int usingPositionX = 0;
int usingPositionY = 0;
int nowMaxEffectiveScore = 0;
List<List<int>> collectPieceArray = CreateCollectPieceArray(ques, ans);

// 仕様メモ
// 左端、もしくは右端を固定し、一方向にしか動かないようにする
// for文を回して、どの型が一番効率的かを計算する
// 効率的かどうかは、(揃ったピースの数-揃わなくなったピースの数)で判断する
// 効率的なものを見つけたら、使うべき型、使うべき座標を返す

for (int useDieIndex = 0; useDieIndex < problemData.General.Patterns.Count; useDieIndex++)
{
for (int x = 0; x < Xmax; x++)
{
for (int y = 0; y < Ymax; y++)
{
int rightCuttingEffectiveScore;
int leftCuttingEffectiveScore;
List<List<int>> tempQues = Case.Copy(ques);
List<List<int>> tempAns = Case.Copy(ans);
List<List<int>> leftCuttingQues = Case.DieCuttingLeft(tempQues, Pattern.PatternList[useDieIndex], y, x, Pattern.PatternList[useDieIndex].GetLength(1), Pattern.PatternList[useDieIndex].GetLength(0));
List<List<int>> rightCuttingQues = Case.DieCuttingRight(tempQues, Pattern.PatternList[useDieIndex], y, x, Pattern.PatternList[useDieIndex].GetLength(1), Pattern.PatternList[useDieIndex].GetLength(0));

List<List<int>> leftCuttingCollectPieceArray = CreateCollectPieceArray(leftCuttingQues, tempAns);
List<List<int>> rightCuttingCollectPieceArray = CreateCollectPieceArray(rightCuttingQues, tempAns);

rightCuttingEffectiveScore = CalculateEffectiveScore(collectPieceArray, rightCuttingCollectPieceArray);
leftCuttingEffectiveScore = CalculateEffectiveScore(collectPieceArray, leftCuttingCollectPieceArray);

if (MathF.Max(rightCuttingEffectiveScore, leftCuttingEffectiveScore) > nowMaxEffectiveScore)
{
nowMaxEffectiveScore = (int)MathF.Max(rightCuttingEffectiveScore, leftCuttingEffectiveScore);
useDieNum = useDieIndex;
usingPositionX = x;
usingPositionY = y;
}
}
}
}

return (useDieNum, cuttingDirection, usingPositionX, usingPositionY);

}

int CalculateEffectiveScore(List<List<int>> beforeCollectPieceArray, List<List<int>> afterCollectPieceArray)
{
int effectiveScore = 0;
for (int y = 0; y < Ymax; y++)
{
for (int x = 0; x < Xmax; x++)
{
effectiveScore += (int)beforeCollectPieceArray[y][x] - afterCollectPieceArray[y][x]

Check failure on line 438 in 2024ProconTemporary/MainAlgorithm.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

; expected

Check failure on line 438 in 2024ProconTemporary/MainAlgorithm.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

; expected

Check failure on line 438 in 2024ProconTemporary/MainAlgorithm.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

; expected

Check failure on line 438 in 2024ProconTemporary/MainAlgorithm.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

; expected
}
}
return effectiveScore;
}

List<List<int>> CreateCollectPieceArray(List<List<int>> ques, List<List<int>> ans)
{
List<List<int>> collectPieceArray = new List<List<int>>();
for (int x = 0; x < Xmax; x++)
{
List<int> collectPieceRaw = new List<int>();
for (int y = 0; y < Ymax; y++)
{
if (ques[y][x] == ans[y][x]) collectPieceRaw.Add(1);
else collectPieceRaw.Add(0);
}
collectPieceArray.Add(collectPieceRaw);
}
return collectPieceArray;
}

}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
// ランタイム バージョン:4.0.30319.42000
// This code was generated by a tool.
//
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
// コードが再生成されるときに損失したりします。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Expand All @@ -14,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("2024ProconTemporary")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2224d9788438e09a2f66a1a6df3af58463175128")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f25c213b0eb164023b5c8f8e1793b8e4b3f20db")]
[assembly: System.Reflection.AssemblyProductAttribute("2024ProconTemporary")]
[assembly: System.Reflection.AssemblyTitleAttribute("2024ProconTemporary")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86fc78adfc98c6fc3e798c758dda2f99f1413c0aab3cec7018efd1cad9520e83
54f31958582c1b29d9a118743e8f8ecb03604e4feeca0f0616ed1621828e6d64

0 comments on commit 18ae997

Please sign in to comment.