Skip to content

Commit

Permalink
Rename type.
Browse files Browse the repository at this point in the history
  • Loading branch information
SunnieShine authored and SunnieShine committed Mar 23, 2024
1 parent 71136de commit ab94bdc
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Sudoku.Analytics.Categorization;
/// <summary>
/// Represents a subtype of the single technique set.
/// </summary>
public enum SingleSubtype
public enum SingleTechniqueSubtype
{
/// <summary>
/// Indicates the subtype is Full House in Block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ from c in covered
/// <param name="house">Indicates the house.</param>
/// <param name="chosenCells">The chosen cells.</param>
/// <returns>The subtype of the hidden single.</returns>
public static SingleSubtype GetHiddenSingleSubtype(
public static SingleTechniqueSubtype GetHiddenSingleSubtype(
scoped ref readonly Grid grid,
Cell cell,
House house,
Expand All @@ -67,7 +67,7 @@ scoped ref readonly CellMap chosenCells
}
}

return Enum.Parse<SingleSubtype>(
return Enum.Parse<SingleTechniqueSubtype>(
house switch
{
>= 0 and < 9 => $"{HouseType.Block}HiddenSingle0{r}{c}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ .. IntersectionModule.GetCrosshatchBaseCells(in grid, digit, baseSet, in interse
digit,
house switch
{
< 9 => SingleSubtype.FullHouseBlock,
< 18 => SingleSubtype.FullHouseRow,
_ => SingleSubtype.FullHouseColumn
< 9 => SingleTechniqueSubtype.FullHouseBlock,
< 18 => SingleTechniqueSubtype.FullHouseRow,
_ => SingleTechniqueSubtype.FullHouseColumn
},
Technique.FullHouse,
baseSet < 9
Expand Down Expand Up @@ -317,7 +317,7 @@ .. IntersectionModule.GetCrosshatchBaseCells(in grid, digit, baseSet, in interse
baseSet,
[lastCell],
digit,
SingleSubtype.NakedSingle0 + (HousesMap[lastCell.ToHouseIndex(HouseType.Block)] - emptyCells).Count,
SingleTechniqueSubtype.NakedSingle0 + (HousesMap[lastCell.ToHouseIndex(HouseType.Block)] - emptyCells).Count,
Technique.NakedSingle,
baseSet < 9
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,9 @@ scoped ref readonly CellMap emptyCells
eliminatedDigitsMask,
houseType switch
{
HouseType.Block => SingleSubtype.FullHouseBlock,
HouseType.Row => SingleSubtype.FullHouseRow,
_ => SingleSubtype.FullHouseColumn
HouseType.Block => SingleTechniqueSubtype.FullHouseBlock,
HouseType.Row => SingleTechniqueSubtype.FullHouseRow,
_ => SingleTechniqueSubtype.FullHouseColumn
},
Technique.FullHouse,
subsetTechnique
Expand Down Expand Up @@ -570,7 +570,7 @@ .. SingleModule.GetNakedSingleExcluders(in grid, cell, lastDigit, out _),
subsetHouse,
[cell],
eliminatedDigitsMask,
SingleSubtype.NakedSingle0 + (HousesMap[cell.ToHouseIndex(HouseType.Block)] - emptyCells).Count,
SingleTechniqueSubtype.NakedSingle0 + (HousesMap[cell.ToHouseIndex(HouseType.Block)] - emptyCells).Count,
Technique.NakedSingle,
subsetTechnique
);
Expand Down Expand Up @@ -671,9 +671,9 @@ scoped ref readonly CellMap emptyCells
eliminatedDigitsMask,
houseType switch
{
HouseType.Block => SingleSubtype.FullHouseBlock,
HouseType.Row => SingleSubtype.FullHouseRow,
_ => SingleSubtype.FullHouseColumn
HouseType.Block => SingleTechniqueSubtype.FullHouseBlock,
HouseType.Row => SingleTechniqueSubtype.FullHouseRow,
_ => SingleTechniqueSubtype.FullHouseColumn
},
Technique.FullHouse,
subsetTechnique
Expand Down Expand Up @@ -831,7 +831,7 @@ .. SingleModule.GetNakedSingleExcluders(in grid, cell, lastDigit, out _),
subsetHouse,
[cell],
eliminatedDigitsMask,
SingleSubtype.NakedSingle0 + (HousesMap[cell.ToHouseIndex(HouseType.Block)] - emptyCells).Count,
SingleTechniqueSubtype.NakedSingle0 + (HousesMap[cell.ToHouseIndex(HouseType.Block)] - emptyCells).Count,
Technique.NakedSingle,
subsetTechnique
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ [[.. SingleModule.GetNakedSingleExcluders(in grid, cell, digit, out _)]],
/// <param name="grid">The grid.</param>
/// <param name="cell">The cell.</param>
/// <returns>The subtype of the naked single.</returns>
private static SingleSubtype GetNakedSingleSubtype(scoped ref readonly Grid grid, Cell cell)
private static SingleTechniqueSubtype GetNakedSingleSubtype(scoped ref readonly Grid grid, Cell cell)
{
var valuesCountInBlock = 0;
foreach (var c in HousesMap[cell.ToHouseIndex(HouseType.Block)])
Expand All @@ -237,15 +237,15 @@ private static SingleSubtype GetNakedSingleSubtype(scoped ref readonly Grid grid
}
return valuesCountInBlock switch
{
0 => SingleSubtype.NakedSingle0,
1 => SingleSubtype.NakedSingle1,
2 => SingleSubtype.NakedSingle2,
3 => SingleSubtype.NakedSingle3,
4 => SingleSubtype.NakedSingle4,
5 => SingleSubtype.NakedSingle5,
6 => SingleSubtype.NakedSingle6,
7 => SingleSubtype.NakedSingle7,
_ => SingleSubtype.NakedSingle8
0 => SingleTechniqueSubtype.NakedSingle0,
1 => SingleTechniqueSubtype.NakedSingle1,
2 => SingleTechniqueSubtype.NakedSingle2,
3 => SingleTechniqueSubtype.NakedSingle3,
4 => SingleTechniqueSubtype.NakedSingle4,
5 => SingleTechniqueSubtype.NakedSingle5,
6 => SingleTechniqueSubtype.NakedSingle6,
7 => SingleTechniqueSubtype.NakedSingle7,
_ => SingleTechniqueSubtype.NakedSingle8
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract partial class ComplexSingleStep(
StepSearcherOptions options,
Cell cell,
Digit digit,
SingleSubtype subtype,
SingleTechniqueSubtype subtype,
[PrimaryConstructorParameter] Technique basedOn,
[PrimaryConstructorParameter] Technique[][] indirectTechniques
) : SingleStep(conclusions, views, options, cell, digit, subtype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed partial class DirectIntersectionStep(
[PrimaryConstructorParameter] House intersectionHouse,
[PrimaryConstructorParameter] scoped ref readonly CellMap interim,
[PrimaryConstructorParameter] Digit interimDigit,
SingleSubtype subtype,
SingleTechniqueSubtype subtype,
Technique basedOn,
[PrimaryConstructorParameter] bool isPointing
) : ComplexSingleStep(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public sealed partial class DirectSubsetStep(
[PrimaryConstructorParameter] House subsetHouse,
[PrimaryConstructorParameter] scoped ref readonly CellMap interim,
[PrimaryConstructorParameter] Mask interimDigitsMask,
SingleSubtype subtype,
SingleTechniqueSubtype subtype,
Technique basedOn,
[PrimaryConstructorParameter] Technique subsetTechnique
) : ComplexSingleStep(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Digit digit
options,
cell,
digit,
house switch { < 9 => SingleSubtype.FullHouseBlock, >= 9 and < 18 => SingleSubtype.FullHouseRow, _ => SingleSubtype.FullHouseColumn }
house switch { < 9 => SingleTechniqueSubtype.FullHouseBlock, >= 9 and < 18 => SingleTechniqueSubtype.FullHouseRow, _ => SingleTechniqueSubtype.FullHouseColumn }
)
{
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class HiddenSingleStep(
Digit digit,
[PrimaryConstructorParameter] House house,
[PrimaryConstructorParameter] bool enableAndIsLastDigit,
SingleSubtype subtype
SingleTechniqueSubtype subtype
) : SingleStep(conclusions, views, options, cell, digit, subtype)
{
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ namespace Sudoku.Analytics.Steps;
/// <param name="digit"><inheritdoc/></param>
/// <param name="house"><inheritdoc/></param>
public sealed class LastDigitStep(Conclusion[] conclusions, View[]? views, StepSearcherOptions options, Cell cell, Digit digit, House house) :
HiddenSingleStep(conclusions, views, options, cell, digit, house, true, SingleSubtype.LastDigit);
HiddenSingleStep(conclusions, views, options, cell, digit, house, true, SingleTechniqueSubtype.LastDigit);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed partial class NakedSingleStep(
StepSearcherOptions options,
Cell cell,
Digit digit,
SingleSubtype subtype
SingleTechniqueSubtype subtype
) : SingleStep(conclusions, views, options, cell, digit, subtype)
{
/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/Sudoku.Analytics/Analytics/Steps/Singles/SingleStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ public abstract partial class SingleStep(
StepSearcherOptions options,
[PrimaryConstructorParameter] Cell cell,
[PrimaryConstructorParameter] Digit digit,
[PrimaryConstructorParameter] SingleSubtype subtype
[PrimaryConstructorParameter] SingleTechniqueSubtype subtype
) : Step(conclusions, views, options);
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Sudoku.Analytics.Categorization;

/// <summary>
/// Provides with extension methods on <see cref="SingleSubtype"/>.
/// Provides with extension methods on <see cref="SingleTechniqueSubtype"/>.
/// </summary>
/// <seealso cref="SingleSubtype"/>
public static class SingleSubtypeExtensions
/// <seealso cref="SingleTechniqueSubtype"/>
public static class SingleTechniqueSubtypeExtensions
{
/// <summary>
/// Indicates whether the specified subtype is unnecessary in practice.
Expand All @@ -13,9 +13,9 @@ public static class SingleSubtypeExtensions
/// <param name="this">The subtype.</param>
/// <returns>A <see cref="bool"/> result indicating whether the subtype is unnecessary.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUnnecessary(this SingleSubtype @this)
=> @this is SingleSubtype.BlockHiddenSingle000 or SingleSubtype.RowHiddenSingle000 or SingleSubtype.ColumnHiddenSingle000
or SingleSubtype.NakedSingle8;
public static bool IsUnnecessary(this SingleTechniqueSubtype @this)
=> @this is SingleTechniqueSubtype.BlockHiddenSingle000 or SingleTechniqueSubtype.RowHiddenSingle000 or SingleTechniqueSubtype.ColumnHiddenSingle000
or SingleTechniqueSubtype.NakedSingle8;

#pragma warning disable format
/// <summary>
Expand All @@ -25,10 +25,10 @@ public static bool IsUnnecessary(this SingleSubtype @this)
/// <param name="this">Indicates the subtype.</param>
/// <returns>The number of excluder value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetExcludersCount(this SingleSubtype @this)
public static int GetExcludersCount(this SingleTechniqueSubtype @this)
=> @this switch
{
>= SingleSubtype.BlockHiddenSingle000 and < SingleSubtype.NakedSingle0 => @this.GetAttribute().ExtraArguments switch
>= SingleTechniqueSubtype.BlockHiddenSingle000 and < SingleTechniqueSubtype.NakedSingle0 => @this.GetAttribute().ExtraArguments switch
{
[int value] => value,
_ => 0
Expand All @@ -43,12 +43,12 @@ public static int GetExcludersCount(this SingleSubtype @this)
/// <param name="this">The subtype.</param>
/// <returns>The related technique instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Technique GetRelatedTechnique(this SingleSubtype @this) => @this.GetAttribute().RelatedTechnique;
public static Technique GetRelatedTechnique(this SingleTechniqueSubtype @this) => @this.GetAttribute().RelatedTechnique;

/// <summary>
/// Gets the attribute.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static TechniqueMetadataAttribute GetAttribute(this SingleSubtype @this)
=> typeof(SingleSubtype).GetField(@this.ToString())!.GetCustomAttribute<TechniqueMetadataAttribute>()!;
private static TechniqueMetadataAttribute GetAttribute(this SingleTechniqueSubtype @this)
=> typeof(SingleTechniqueSubtype).GetField(@this.ToString())!.GetCustomAttribute<TechniqueMetadataAttribute>()!;
}
Loading

0 comments on commit ab94bdc

Please sign in to comment.