Exemple #1
0
        public void Save(GoodMove store, Move uMaskedMove, BottleHash uBottleHash, Int32 nSide)
        {
            var uIndex   = index(uBottleHash);
            var bReplace = true;        // Assume final write needed
            var bFound   = false;
            var nKiller  = 0;

            for (; nKiller < nKillers; nKiller++)
            {
                var gm = Killers[nSide][nKiller][uIndex];
                if (!isDefined(gm.Move))
                {
                    break;
                }
                else if (equalMoves(uMaskedMove, gm.Move))
                {
                    bFound = true;
                    break;
                }
            }

            if (bFound)
            {
                bReplace = false;
            }
            else
            {
                if (nKiller < nKillers) // Bottle Not Full: Add newest and return
                {
                    Killers[nSide][nKiller][uIndex] = store;
                    return;
                }
                else
                {
                    nKiller = 0;        // Bottle Full: Remove Oldest Entry
                }
            }

            for (; nKiller + 1 < nKillers; nKiller++)
            {
                var gm = Killers[nSide][nKiller + 1][uIndex];
                if (!isDefined(gm.Move))
                {
                    break;
                }

                Killers[nSide][nKiller][uIndex] = gm;
                bReplace = true;
            }

            if (bReplace)
            {
                Killers[nSide][nKiller][uIndex] = store;
            }
        }
Exemple #2
0
 public void Clear()
 {
     for (var nSide = 0; nSide < nBottleSides; nSide++)
     {
         for (var nKiller = 0; nKiller < nKillers; nKiller++)
         {
             for (var uIndex = 0U; uIndex < BottleLength; uIndex++)
             {
                 Killers[nSide][nKiller][uIndex] = new GoodMove();
             }
         }
     }
 }
Exemple #3
0
        protected void allocate(UInt32 uBottleLength)
        {
            if (nKillers > 0)
            {
                Killers = new GoodMove[nBottleSides][][];
                for (var nSide = 0; nSide < nBottleSides; nSide++)
                {
                    Killers[nSide] = new GoodMove[nKillers][];
                    for (var nKiller = 0; nKiller < nKillers; nKiller++)
                    {
                        Killers[nSide][nKiller] = new GoodMove[uBottleLength];
                    }
                }
            }

            BottleLength = uBottleLength;
        }