Пример #1
0
            public virtual MoveNode addSubMove(short move)
            {
                MoveNode subMove = new MoveNode(move, this, outerInstance.config);

                followingMoves.Add(subMove);
                return(subMove);
            }
Пример #2
0
        public virtual bool checkSymmetry(MoveNode move)
        {
            StringBuilder SymmetryString = new StringBuilder(config.pegs);
            int           UnusedNumber   = 0;
            bool          anySymmetries  = false;
            bool          allUnused      = true;

            int[] currentSet = move.SinglePegs;

            for (int i = 0; i < currentSet.Length; i++)             // loop through
            {
                // the currently
                // tested move
                int peg = currentSet[i];             // select a peg
                if (!colorUsed[peg])                 // if that color hasn't been used yet
                {
                    // --> free color
                    anySymmetries = true;
                    for (int z = 0; z < i; z++)                     // check whether we already had
                    {
                        // that color marked unused
                        if (alphabet.Contains(SymmetryString[z] + "") && currentSet[z] == peg)
                        {
                            SymmetryString.Append(SymmetryString[z]);
                            goto pegLoopContinue;
                        }
                    }
                    SymmetryString.Append(alphabet[UnusedNumber]);
                    UnusedNumber++;
                }
                else if (colorFalse[peg])
                {
                    SymmetryString.Append("z");
                    anySymmetries = true;
                    allUnused     = false;
                }
                else
                {
                    SymmetryString.Append(peg);
                    allUnused = false;
                }
                pegLoopContinue :;
            }
            if (anySymmetries)
            {
                string sym = SymmetryString.ToString();
                if (!SymmetrySet.TryAdd(sym, 0))
                {
                    return(false);
                }
                if (allUnused)
                {
                    permutation("", sym);
                }
            }
            return(true);
        }
Пример #3
0
 public virtual void addSubNode(MoveNode node)
 {
     followingMoves.Add(node);
 }
Пример #4
0
 protected internal GradeNode(MoveNode outerInstance, int gradeID)
 {
     this.outerInstance = outerInstance;
     this.gradeID       = gradeID;
     init();
 }