コード例 #1
0
        private List <RubickColorMatrix> GetBestNeighbors(RubickColorMatrix _node)
        {
            List <RubickColorMatrix> neighbors = new List <RubickColorMatrix>();
            int min = int.MaxValue;
            RubickColorMatrix minNeightbor = null;

            var moves = System.Enum.GetValues(typeof(RubickMovementTypes));

            for (int i = 0; i < moves.Length; i++)
            {
                RubickMovementTypes val = (RubickMovementTypes)moves.GetValue(i);
                if (val != RubickMovementTypes.None)
                {
                    RubickColorMatrix clone = (RubickColorMatrix)_node.Clone();
                    clone.Transform(val);
                    int cost = clone.HeuristicCostEstimate();
                    if (cost < min)
                    {
                        min          = cost;
                        minNeightbor = clone;
                    }
                }
            }

            if (min == _node.HeuristicCostEstimate())
            {
                UnityEngine.Debug.Log("Duh");
            }
            neighbors.Add(minNeightbor);
            return(neighbors);
        }
コード例 #2
0
        public int getHeuristicValue(object state)
        {
            RubickColorMatrix node = (RubickColorMatrix)state;

            return(node.HeuristicCostEstimate());
        }
コード例 #3
0
 private int HeuristicCostEstimate(RubickColorMatrix _node)
 {
     return(_node.HeuristicCostEstimate());
 }