예제 #1
0
 private static byte[] Decode(byte[] bytes, int startIndex, ITreeNode tree)
 {
     List<byte> outputBytes = new List<byte>(bytes.Length);
     TreeSearcher searcher = new TreeSearcher(tree);
     for (int i = startIndex; i < bytes.Length; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             byte? b = searcher.Move(bytes[i].GetBit(j));
             if (b.HasValue)
             {
                 outputBytes.Add(b.Value);
             }
         }
     }
     return outputBytes.ToArray();
 }
예제 #2
0
        private static byte[] Decode(byte[] bytes, int startIndex, ITreeNode tree)
        {
            List <byte>  outputBytes = new List <byte>(bytes.Length);
            TreeSearcher searcher    = new TreeSearcher(tree);

            for (int i = startIndex; i < bytes.Length; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    byte?b = searcher.Move(bytes[i].GetBit(j));
                    if (b.HasValue)
                    {
                        outputBytes.Add(b.Value);
                    }
                }
            }
            return(outputBytes.ToArray());
        }
예제 #3
0
        internal Card PlayCard()
        {
            var context   = new PlayingContext(mGame);
            var rootState = new PlayingState(context);

            var validMoves = rootState.GetValidMoves();

            // Exit if only one move is possible.
            if (BitwiseCardHelper.GetGroupCount(validMoves) == 1)
            {
                return(GetRandomCard(validMoves));
            }

            bool isCheater = (mGame.Options.DifficultyLevel == GameDifficultyLevel.Cheater);
            var  bestNode  = TreeSearcher.Search(rootState, 100000, !isCheater);

            return(GetRandomCard(bestNode.Move.Group));
        }
예제 #4
0
        /**
         * Searches the HashTree structure for the given key. If it finds the key,
         * it returns the HashTree mapped to the key. If it finds nothing, it
         * returns null.
         *
         * @param key
         *            Key to search for
         * @return HashTree mapped to key, if found, otherwise <code>null</code>
         */
        public HashTree Search(Object key)
        {// TODO does not appear to be used
            HashTree result = GetTree(key);

            if (result != null)
            {
                return(result);
            }
            TreeSearcher searcher = new TreeSearcher(key);

            try
            {
                Traverse(searcher);
            }
            catch (Exception ex)
            {
                if (!ex.Message.Equals(FOUND))
                {
                    throw ex;
                }
                // do nothing - means object is found
            }
            return(searcher.GetResult());
        }