Exemplo n.º 1
0
 public EngineStats ResetStatisticsLog()
 {
     if (collectStats)
     {
         EngineStats old = Stats;
         Stats = new EngineStats();
         return(old);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initialises the common engine elements.
        /// </summary>
        /// <param name="eval">The class used to evaluate GameStates searched by this engine</param>
        /// <param name="timeLimit">The maximum time allowed for search, in seconds. Must be greater than 0</param>
        /// <param name="depthLimit">The maximum depth to search in the GameState search tree. Also called "ply". Must be at least 1</param>
        /// <param name="timeLimited">If set to <c>true</c> Search will end after the set timeLimit, otherwise
        /// search will complete to the set depthLimit</param>
        /// <param name="collectStats">If set to <c>true</c> collect statistics.</param>
        protected void InitEngine(IEvaluator eval, float timeLimit, int depthLimit, bool timeLimited, bool collectStats)
        {
            if (timeLimit <= 0)
            {
                throw new ArgumentOutOfRangeException("timeLimit", "Must be greater than 0");
            }
            if (depthLimit <= 0)
            {
                throw new ArgumentOutOfRangeException("depthLimit", "Must be at least 1");
            }
            this.timeLimited  = timeLimited;
            this.collectStats = collectStats;
            this.maxTime      = timeLimit;
            this.maxDepth     = depthLimit;
            if (collectStats)
            {
                Stats = new EngineStats();
            }

            this.eval = eval;

            rando = new System.Random((int)DateTime.Now.Ticks);
        }