当前位置: 首页>>代码示例>>C#>>正文


C# CubeFlag类代码示例

本文整理汇总了C#中CubeFlag的典型用法代码示例。如果您正苦于以下问题:C# CubeFlag类的具体用法?C# CubeFlag怎么用?C# CubeFlag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CubeFlag类属于命名空间,在下文中一共展示了CubeFlag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的CubeFlag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。