Exemplo n.º 1
0
        public void AddKey(ColorCombination key, Color value, int index)
        {
            //ALWAYS IN ORDER.
            chainLeprechauns.Add(key, value);
            List <Color> listCorrect   = new List <Color>();
            List <Color> listIncorrect = new List <Color>();
            List <Color> x             = key.GetList;
            int          k             = 0;

            for (int i = 0; i < x.Count + 1; i++)
            {
                if (i != index)
                {
                    listCorrect.Add(x[k]);
                    listIncorrect.Add(x[k]);
                    k++;
                }
                else
                {
                    listCorrect.Add(value);
                    listIncorrect.Add(value);
                }
            }

            ColorCombination correctAnswer   = new ColorCombination(listCorrect);
            ColorCombination incorrectAnswer = new ColorCombination(listIncorrect);

            correctAnswers.Add(correctAnswer);
            incorrectAnswers.Add(incorrectAnswer);
        }
Exemplo n.º 2
0
        public ColorCombination GetWithout(int i)
        {
            List <Color> indexList = new List <Color>();

            indexList.Add(GetAt(i));
            ColorCombination returnCom = new ColorCombination(combination.Except(indexList).ToList());

            return(returnCom);
        }
Exemplo n.º 3
0
        public void CompleteChain(int chainLength)
        {
            //Step 1 : Wrong Answer of the Chain
            ColorCombination c = incorrectAnswers[0];

            //Step 2 : Fill all the leprechauns chain slots.
            for (int i = 1; i < chainLength; i++)
            {
                ColorCombination newCombi = c.GetWithout(i);
                Color            newColor = c.GetAt(i).Inverse();
                AddKey(newCombi, newColor, i);
            }
        }
Exemplo n.º 4
0
 public bool Compare(ColorCombination colorCombination)
 {
     for (int i = 0; i < combination.Count; i++)
     {
         Color c = combination[i];
         Color d = colorCombination.GetList[i];
         if (c.Compare(d))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 5
0
        //Public Functions
        public void Initialize()
        {
            //LoopIncrements
            int i, j;

            //Func 1 : Create Combinations
            #region Func 1
            int remainingLepri = nLepri - 1;
            int loopCombi      = (int)Math.Pow(mColor, remainingLepri);
            //Step 1 : Loop for all color possibilities on the remaining
            for (i = 0; i < loopCombi; i++)
            {
                //Step 2: Create a new Combination
                #region Example

                /* N = 3
                 * M = 2, { Red, Blue }
                 * loop = 4
                 * Color Combinations
                 * RR RB BR BB
                 */
                #endregion
                ColorCombination comb = new ColorCombination(remainingLepri);
                for (j = 0; j < remainingLepri; j++)
                {
                    Color c = new Color(((i / (int)Math.Pow(mColor, j)) % mColor), false);
                    comb.SetLepri(j, c);
                }
                combinations.Add(comb);
            }
            #endregion
            //Func 2 : Create Chains
            #region Func 2
            int loopChains = mColor * loopCombi;
            for (i = 0; i < loopChains; i++)
            {
                Chain            newChain = new Chain(combinations, i + 1);
                ColorCombination combo    = combinations[i / mColor];
                Color            c        = new Color(i % mColor, false);
                newChain.AddStart(combo, c);
                newChain.CompleteChain(nLepri);
                chains.Add(newChain);
            }
            //Func3 : Create Overlapping chains list
            NoOverlap();
            #endregion
        }
Exemplo n.º 6
0
 //Public Functions
 public void AddStart(ColorCombination key, Color value)
 {
     AddKey(key, value, 0);
 }
Exemplo n.º 7
0
        private bool LookAtLeprechaun(int lepreIndex, ColorCombination combi, int indexColor)
        {
            KeyValuePair <ColorCombination, Color> lepreAnswer = chainLeprechauns.ElementAt(lepreIndex);

            return(lepreAnswer.Key == combi && lepreAnswer.Value == new Color(indexColor, true));
        }
Exemplo n.º 8
0
        private bool LookAtLeprechaun(int lepreIndex, ColorCombination combi, string color)
        {
            KeyValuePair <ColorCombination, Color> lepreAnswer = chainLeprechauns.ElementAt(lepreIndex);

            return(lepreAnswer.Key == combi && lepreAnswer.Value.GetString() == color);
        }