本文整理汇总了C#中CubeFlag类的典型用法代码示例。如果您正苦于以下问题:C# CubeFlag类的具体用法?C# CubeFlag怎么用?C# CubeFlag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CubeFlag类属于命名空间,在下文中一共展示了CubeFlag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindMatches
/// <summary>
/// Finds all possible algorithms for this pattern
/// </summary>
/// <param name="p">Current rubik pattern</param>
/// <param name="rotationLayer">Transformation rotation</param>
/// <returns>Returns all possible solutions for this pattern</returns>
public Dictionary<Pattern, Algorithm> FindMatches(Pattern p, CubeFlag rotationLayer, PatternFilter filter)
{
Dictionary<Pattern, Algorithm> transformedPatterns = Patterns.ToDictionary(kvp => kvp.Key.DeepClone(), a => a.Value); // clone
Dictionary<Pattern,Algorithm> filteredPatterns = transformedPatterns.Where(kvp => filter.Filter(p, kvp.Key)).ToDictionary(pa => pa.Key, a => a.Value); // filter
filteredPatterns = filteredPatterns.OrderByDescending(k => k.Key.Probability).ToDictionary(pa => pa.Key.DeepClone(), a => a.Value); // order by probability
Dictionary<Pattern, Algorithm> matches = new Dictionary<Pattern, Algorithm>();
// 4 possible standard transformations
for (int i = 0; i < 4; i++)
{
// Get matches
foreach (KeyValuePair<Pattern, Algorithm> kvp in filteredPatterns.Where(pa => p.IncludesAllPatternElements(pa.Key)))
{
matches.Add(kvp.Key, kvp.Value); // Add to matches
}
if (rotationLayer == CubeFlag.None) return matches;
if (filter.OnlyAtBeginning)
{
transformedPatterns = filteredPatterns.Except(matches).ToDictionary(pa => pa.Key.Transform(rotationLayer), a => a.Value.Transform(rotationLayer));
filteredPatterns = transformedPatterns;
}
else
{
transformedPatterns = transformedPatterns.ToDictionary(pa => pa.Key.Transform(rotationLayer), a => a.Value.Transform(rotationLayer));
filteredPatterns = transformedPatterns.Where(kvp => filter.Filter(p, kvp.Key)).ToDictionary(pa => pa.Key, a => a.Value);
}
}
return matches;
}
开发者ID:Borsos,项目名称:RubiksCubeSolver-1,代码行数:36,代码来源:PatternTable.cs
示例2: Cube3D
/// <summary>
/// Initializes a new instance of the Cube3D class
/// </summary>
/// <param name="faces">Faces</param>
/// <param name="position">Position</param>
public Cube3D(IEnumerable<Face3D> faces, CubeFlag position, Point3D location, double scale)
{
this.Faces = faces;
this.Position = position;
this.Location = location;
this.Scale = scale;
}
开发者ID:ArcaneSaint,项目名称:PXL_Programming_Expert_RubiksCubeSolver,代码行数:12,代码来源:Cube3D.cs
示例3: IsPossibleMove
// **** METHODS ****
/// <summary>
/// Returns true if the given CubeFlag contains a valid move
/// </summary>
/// <param name="flags">Defines the CubeFlag to be analyzed</param>
/// <returns></returns>
public static bool IsPossibleMove(CubeFlag flags)
{
flags = ExceptFlag(flags, CubeFlag.None);
return GetFlags(flags).All(f => IsXFlag((CubeFlag)f)) ||
GetFlags(flags).All(f => IsYFlag((CubeFlag)f)) ||
GetFlags(flags).All(f => IsZFlag((CubeFlag)f));
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:14,代码来源:CubeFlagService.cs
示例4: Face3D
// *** CONSTRUCTOR ***
/// <summary>
/// Initializes a new instance of the Face3D class
/// </summary>
/// <param name="vertices">Vertices of the 3D face</param>
/// <param name="color">Color</param>
/// <param name="position">Position</param>
/// <param name="masterPosition">Position of the parent 3D cube</param>
public Face3D(IEnumerable<Point3D> vertices, Color color, FacePosition position, CubeFlag masterPosition)
{
this.Vertices = vertices;
this.Color = color;
this.Position = position;
this.MasterPosition = masterPosition;
}
开发者ID:Borsos,项目名称:RubiksCubeSolver-1,代码行数:16,代码来源:Face3D.cs
示例5: Cube
/// <summary>
/// Constructor with faces and position
/// </summary>
/// <param name="faces">Defines the faces where the cube belongs to</param>
/// <param name="position">Defines the position of the cube</param>
public Cube(IEnumerable<Face> faces, CubeFlag position)
{
this.Faces = faces;
this.Position = new CubePosition(position);
this.Colors = new List<Color>();
this.Colors.Clear();
this.Faces.ToList().ForEach(f => Colors.Add(f.Color));
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver,代码行数:13,代码来源:Cube.cs
示例6: GenFaces3D
/// <summary>
/// Returns a collection with six entries containing the six Faces3D with a black color
/// </summary>
/// <param name="masterPosition">Defines the master position of the Faces3D</param>
/// <returns></returns>
public static IEnumerable<Face3D> GenFaces3D(CubeFlag masterPosition) => new[] {
new Face3D(new[] { new Point3D(-1, 1, -1), new Point3D(1, 1, -1), new Point3D(1, -1, -1), new Point3D(-1, -1, -1) }, Color.Black, FacePosition.Front, masterPosition),
new Face3D(new[] { new Point3D(-1, 1, 1), new Point3D(1, 1, 1), new Point3D(1, -1, 1), new Point3D(-1, -1, 1) }, Color.Black, FacePosition.Back, masterPosition),
new Face3D(new[] { new Point3D(-1, -1, -1), new Point3D(1, -1, -1), new Point3D(1, -1, 1), new Point3D(-1, -1, 1) }, Color.Black, FacePosition.Top, masterPosition),
new Face3D(new[] { new Point3D(-1, 1, -1), new Point3D(1, 1, -1), new Point3D(1, 1, 1), new Point3D(-1, 1, 1) }, Color.Black, FacePosition.Bottom, masterPosition),
new Face3D(new[] { new Point3D(1, 1, 1), new Point3D(1, 1, -1), new Point3D(1, -1, -1), new Point3D(1, -1, 1) }, Color.Black, FacePosition.Right, masterPosition),
new Face3D(new[] { new Point3D(-1, 1, 1), new Point3D(-1, 1, -1), new Point3D(-1, -1, -1), new Point3D(-1, -1, 1) }, Color.Black, FacePosition.Left, masterPosition)
};
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:13,代码来源:UniCube.cs
示例7: IsCorner
// **** METHODS ****
/// <summary>
/// Returns true if the given CubeFlag describes a corner cube
/// </summary>
/// <param name="position">Defines the CubeFlag to be analyzed</param>
/// <returns></returns>
public static bool IsCorner(CubeFlag position) => ((position == (CubeFlag.TopLayer | CubeFlag.FrontSlice | CubeFlag.LeftSlice))
|| (position == (CubeFlag.TopLayer | CubeFlag.FrontSlice | CubeFlag.RightSlice))
|| (position == (CubeFlag.TopLayer | CubeFlag.BackSlice | CubeFlag.LeftSlice))
|| (position == (CubeFlag.TopLayer | CubeFlag.BackSlice | CubeFlag.RightSlice))
|| (position == (CubeFlag.BottomLayer | CubeFlag.FrontSlice | CubeFlag.LeftSlice))
|| (position == (CubeFlag.BottomLayer | CubeFlag.FrontSlice | CubeFlag.RightSlice))
|| (position == (CubeFlag.BottomLayer | CubeFlag.BackSlice | CubeFlag.LeftSlice))
|| (position == (CubeFlag.BottomLayer | CubeFlag.BackSlice | CubeFlag.RightSlice)));
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:15,代码来源:CubePosition.cs
示例8: Transform
/// <summary>
/// Transforms the algorithm
/// </summary>
/// <param name="rotationLayer">Transformation layer</param>
/// <returns>Transformed algorithm</returns>
public Algorithm Transform(CubeFlag rotationLayer)
{
var newAlgorithm = new Algorithm();
for (var i = 0; i < this.Moves.Count; i++)
{
newAlgorithm.Moves.Add(this.Moves[i].Transform(rotationLayer));
}
return newAlgorithm;
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:14,代码来源:Algorithm.cs
示例9: TestCubePosition
public bool TestCubePosition(Cube c, CubeFlag endPos)
{
foreach(LayerMove move in Algorithm.Moves)
{
Rubik.RotateLayer(move);
}
bool result = RefreshCube(c).Position.HasFlag(endPos);
return result;
}
开发者ID:Borsos,项目名称:RubiksCubeSolver-1,代码行数:9,代码来源:TestScenario.cs
示例10: TestCubePosition
public bool TestCubePosition(Cube c, CubeFlag endPos)
{
foreach (var move in this.Algorithm.Moves.Cast<LayerMove>())
{
this.Rubik.RotateLayer(move);
}
var result = this.RefreshCube(c).Position.HasFlag(endPos);
return result;
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:9,代码来源:TestScenario.cs
示例11: Transform
/// <summary>
/// Transforms the algorithm
/// </summary>
/// <param name="rotationLayer">Transformation layer</param>
/// <returns>Transformed algorithm</returns>
public Algorithm Transform(CubeFlag rotationLayer)
{
Algorithm newAlgorithm = new Algorithm();
for (int i = 0; i < Moves.Count; i++)
{
newAlgorithm.Moves.Add(Moves[i].Transform(rotationLayer));
}
return newAlgorithm;
}
开发者ID:Borsos,项目名称:RubiksCubeSolver-1,代码行数:14,代码来源:Algorithm.cs
示例12: FirstNotInvalidFlag
/// <summary>
/// Returns the first flag in the first parameter which the second parameter does not contain
/// </summary>
/// <param name="flags">Defines the posiible flags to be returned</param>
/// <param name="invalid">Defines the invalid flags</param>
/// <returns></returns>
public static CubeFlag FirstNotInvalidFlag(CubeFlag flags, CubeFlag invalid)
{
foreach (CubeFlag f in GetFlags(flags))
{
if (!invalid.HasFlag(f))
return f;
}
return CubeFlag.None;
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver,代码行数:15,代码来源:CubeFlagService.cs
示例13: ExceptFlag
/// <summary>
/// Returns a ClubFlag which contains all single flags in the first parameter which don't exist in the second parameter
/// </summary>
/// <param name="flags">Defines all possible flags</param>
/// <param name="invalid">Defines the flags to be filtered out of the first parameter</param>
/// <returns></returns>
public static CubeFlag ExceptFlag(CubeFlag flags, CubeFlag invalid)
{
CubeFlag pos = CubeFlag.None;
foreach (CubeFlag p in GetFlags(flags))
{
if (!invalid.HasFlag(p))
pos |= p;
}
return pos;
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver,代码行数:16,代码来源:CubeFlagService.cs
示例14: CommonFlags
/// <summary>
/// Returns a CubeFlag which contains all flags which exist in both the first and the second parameter
/// </summary>
/// <param name="first">Defines the first CubeFlag</param>
/// <param name="second">Defines the second CubeFlag</param>
/// <returns></returns>
public static CubeFlag CommonFlags(CubeFlag first, CubeFlag second)
{
CubeFlag commonFlags = CubeFlag.None;
foreach (CubeFlag flag in GetFlags(first))
{
if (second.HasFlag(flag))
commonFlags |= flag;
}
return commonFlags;
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver,代码行数:16,代码来源:CubeFlagService.cs
示例15: LayerMove
// *** CONSTRUCTORS ***
/// <summary>
/// Constructor
/// </summary>
/// <param name="layer">Defines the layer to be moved</param>
/// <param name="direction">Defines the direction (true == clockwise and false == counter-clockwise)</param>
/// <param name="twice">Defines whether this layer will be turned twice or not</param>
/// <exception cref="System.Exception">Thrown when layer contains more than one flag</exception>
public LayerMove(CubeFlag layer, bool direction = true, bool twice = false)
{
if (CubeFlagService.CountFlags(layer) == 1)
{
this.Layer = layer;
this.Direction = direction;
this.Twice = twice;
}
else
throw new Exception("Impossible movement");
}
开发者ID:Borsos,项目名称:RubiksCubeSolver-1,代码行数:20,代码来源:LayerMove.cs
示例16: IsEdge
/// <summary>
/// Returns true if the given CubeFlag describes a edge cube
/// </summary>
/// <param name="position">Defines the CubeFlag to be analyzed</param>
/// <returns></returns>
public static bool IsEdge(CubeFlag position) => ((position == (CubeFlag.TopLayer | CubeFlag.FrontSlice | CubeFlag.MiddleSliceSides))
|| (position == (CubeFlag.TopLayer | CubeFlag.BackSlice | CubeFlag.MiddleSliceSides))
|| (position == (CubeFlag.TopLayer | CubeFlag.RightSlice | CubeFlag.MiddleSlice))
|| (position == (CubeFlag.TopLayer | CubeFlag.LeftSlice | CubeFlag.MiddleSlice))
|| (position == (CubeFlag.MiddleLayer | CubeFlag.FrontSlice | CubeFlag.RightSlice))
|| (position == (CubeFlag.MiddleLayer | CubeFlag.FrontSlice | CubeFlag.LeftSlice))
|| (position == (CubeFlag.MiddleLayer | CubeFlag.BackSlice | CubeFlag.RightSlice))
|| (position == (CubeFlag.MiddleLayer | CubeFlag.BackSlice | CubeFlag.LeftSlice))
|| (position == (CubeFlag.BottomLayer | CubeFlag.FrontSlice | CubeFlag.MiddleSliceSides))
|| (position == (CubeFlag.BottomLayer | CubeFlag.BackSlice | CubeFlag.MiddleSliceSides))
|| (position == (CubeFlag.BottomLayer | CubeFlag.RightSlice | CubeFlag.MiddleSlice))
|| (position == (CubeFlag.BottomLayer | CubeFlag.LeftSlice | CubeFlag.MiddleSlice)));
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:17,代码来源:CubePosition.cs
示例17: ToInt
/// <summary>
/// Converts a CubeFlag into values from -1 to 1
/// </summary>
/// <param name="flag">todo: describe flag parameter on ToInt</param>
/// <exception cref="Exception">Thrown when the CubeFlag is either invalid or has more than one flag</exception>
public static int ToInt(CubeFlag flag)
{
if (IsXFlag(flag))
{
switch (flag)
{
case CubeFlag.RightSlice:
return 1;
case CubeFlag.MiddleSliceSides:
return 0;
default:
return -1;
}
}
if (IsYFlag(flag))
{
switch (flag)
{
case CubeFlag.TopLayer:
return -1;
case CubeFlag.MiddleLayer:
return 0;
default:
return 1;
}
}
if (IsZFlag(flag))
{
switch (flag)
{
case CubeFlag.BackSlice:
return 1;
case CubeFlag.MiddleSlice:
return 0;
default:
return -1;
}
}
if (flag == CubeFlag.None)
return 0;
throw new Exception("Flag can not be converted to an integer");
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:53,代码来源:CubeFlagService.cs
示例18: InitPatterns
private void InitPatterns(CubeFlag r, CubeFlag f)
{
var l = CubeFlagService.GetOppositeFlag(r);
var b = CubeFlagService.GetOppositeFlag(f);
var rIsX = CubeFlagService.IsXFlag(r);
// edge orientation changes depending on the target slot
var correct = (r == CubeFlag.BackSlice && f == CubeFlag.RightSlice) || (f == CubeFlag.LeftSlice && r == CubeFlag.FrontSlice)
? Orientation.Correct : Orientation.Clockwise;
var clockwise = correct == Orientation.Correct ? Orientation.Clockwise : Orientation.Correct;
this.patterns = new Dictionary<Pattern, Algorithm> {
#region Corner correct oriented at targetposition
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(CubeFlag.TopLayer | f | (rIsX ? CubeFlag.MiddleSliceSides : CubeFlag.MiddleSlice)), correct, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Correct, this.CornerTargetPos)
}),
new Algorithm("U {0} U {0}' U' {1}' U' {1}",CubeFlagService.ToNotationString(r), CubeFlagService.ToNotationString(f))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(CubeFlag.TopLayer | r | (!rIsX ? CubeFlag.MiddleSliceSides : CubeFlag.MiddleSlice)), clockwise, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Correct, this.CornerTargetPos)
}),
new Algorithm("U' {1}' U' {1} U {0} U {0}'",CubeFlagService.ToNotationString(r), CubeFlagService.ToNotationString(f))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(this.EdgeTargetPos), Orientation.Clockwise, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Correct, this.CornerTargetPos)
}),
new Algorithm("{0}2 U2 {1} {0}2 {1}' U2 {0}' U {0}'",CubeFlagService.ToNotationString(r), CubeFlagService.ToNotationString(f))
},
#endregion
#region Corner clockwise oriented at target position
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(CubeFlag.TopLayer | f | (rIsX ? CubeFlag.MiddleSliceSides : CubeFlag.MiddleSlice)), correct, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.CounterClockwise, this.CornerTargetPos)
}),
new Algorithm("{0}' U {0} U' {0}' U {0}",CubeFlagService.ToNotationString(f))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(CubeFlag.TopLayer | r | (!rIsX ? CubeFlag.MiddleSliceSides : CubeFlag.MiddleSlice)), clockwise, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.CounterClockwise, this.CornerTargetPos)
}),
new Algorithm("{0} U {0}' U' {0} U {0}'",CubeFlagService.ToNotationString(r))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(this.EdgeTargetPos), Orientation.Correct, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.CounterClockwise, this.CornerTargetPos)
}),
new Algorithm("{0} U2 {0} U {0}' U {0} U2 {0}2",CubeFlagService.ToNotationString(r))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(this.EdgeTargetPos), Orientation.Clockwise, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.CounterClockwise, this.CornerTargetPos)
}),
new Algorithm("{0} U {0}' U' {0} U' {0}' U2 {1}' U' {1}",CubeFlagService.ToNotationString(r), CubeFlagService.ToNotationString(f))
},
#endregion
#region Corner counter-clockwise oriented at target position
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(CubeFlag.TopLayer | f | (rIsX ? CubeFlag.MiddleSliceSides : CubeFlag.MiddleSlice)), correct, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Clockwise, this.CornerTargetPos)
}),
new Algorithm("{0}' U' {0} U {0}' U' {0}",CubeFlagService.ToNotationString(f))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(CubeFlag.TopLayer | r | (!rIsX ? CubeFlag.MiddleSliceSides : CubeFlag.MiddleSlice)), clockwise, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Clockwise, this.CornerTargetPos)
}),
new Algorithm("{0} U' {0}' U {0} U' {0}'",CubeFlagService.ToNotationString(r))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(this.EdgeTargetPos), Orientation.Correct, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Clockwise, this.CornerTargetPos)
}),
new Algorithm("{0}' U' {0} U2 {0}' U {0} U' {0}' U' {0}",CubeFlagService.ToNotationString(f))
},
{
new Pattern(new List<PatternItem> {
new PatternItem(new CubePosition(this.EdgeTargetPos), Orientation.Clockwise, this.EdgeTargetPos),
new PatternItem(new CubePosition(this.CornerTargetPos), Orientation.Clockwise, this.CornerTargetPos)
}),
new Algorithm("{1}' U' {1} U {1}' U {1} U2 {0} U {0}'",CubeFlagService.ToNotationString(r), CubeFlagService.ToNotationString(f))
},
#endregion
#region Corner correct oriented in top layer
{
//.........这里部分代码省略.........
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:101,代码来源:F2LPattern.cs
示例19: F2LPattern
public F2LPattern(CubeFlag edgeTargetPos, CubeFlag cornerTargetPos, CubeFlag rightSlice, CubeFlag frontSlice)
{
this.CornerTargetPos = cornerTargetPos;
this.EdgeTargetPos = edgeTargetPos;
this.InitPatterns(rightSlice, frontSlice);
}
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:6,代码来源:F2LPattern.cs
示例20: FirstZFlag
/// <summary>
/// Returns the first ZFlag in the given CubeFlag
/// </summary>
/// <param name="flags">Defines the CubeFlag to be analyzed</param>
/// <returns></returns>
public static CubeFlag FirstZFlag(CubeFlag flags) => FirstNotInvalidFlag(flags, CubeFlag.XFlags | CubeFlag.YFlags);
开发者ID:GertClaeskens,项目名称:RubiksCubeSolver_Bewerkt,代码行数:6,代码来源:CubeFlagService.cs
注:本文中的CubeFlag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论