Ejemplo n.º 1
0
        /// <summary>
        /// Evaluates this node in the decision tree.
        /// If the return value is true then move will contain the desired move (if any).
        /// </summary>
        /// <param name="state">The current state of the game.</param>
        /// <param name="move">If this node wants to make a move then it will be placed in this parameter.</param>
        /// <returns>Returns true if this node is satisfied and false otherwise.</returns>
        /// <remarks>Although move must be initialized, that does not mean it is not null.</remarks>
        protected internal override bool Evaluate(GameState <M> state, ref M move)
        {
            IEnumerable <Node <M> > chldrn = Children;

            InnerNode.RemoveAllChildren();
            InnerNode.AddChildren(chldrn);

            return(InnerNode.Evaluate(state, ref move));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluates this node in the decision tree.
        /// If the return value is true then move will contain the desired move (if any).
        /// </summary>
        /// <param name="state">The current state of the game.</param>
        /// <param name="move">If this node wants to make a move then it will be placed in this parameter.</param>
        /// <returns>Returns true if this node is satisfied and false otherwise.</returns>
        /// <remarks>Although move must be initialized, that does not mean it is not null.</remarks>
        protected internal override bool Evaluate(GameState <M> state, ref M move)
        {
            watch.Restart();
            bool ret = InnerNode.Evaluate(state, ref move);

            watch.Stop();

            if (randomized && watch.Elapsed.TotalSeconds < max_time)
            {
                System.Threading.Thread.Sleep((int)((rand.NextDouble() * (max_time - min_time) + min_time - watch.Elapsed.TotalSeconds) * 1000.0));
            }
            else if (watch.Elapsed.TotalSeconds < min_time)            // If we are randomized but greater than max we certainly won't be less than min
            {
                System.Threading.Thread.Sleep((int)((min_time - watch.Elapsed.TotalSeconds) * 1000.0));
            }

            return(ret);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Evaluates this node in the decision tree.
 /// If the return value is true then move will contain the desired move (if any).
 /// </summary>
 /// <param name="state">The current state of the game.</param>
 /// <param name="move">If this node wants to make a move then it will be placed in this parameter.</param>
 /// <returns>Returns true if this node is satisfied and false otherwise.</returns>
 /// <remarks>Although move must be initialized, that does not mean it is not null.</remarks>
 protected internal override bool Evaluate(GameState <M> state, ref M move)
 {
     return(!InnerNode.Evaluate(state, ref move));
 }