Пример #1
0
        /// <summary>
        /// Create a new Node as MinNode or MaxNode
        /// </summary>
        /// <param name="a">Action in Node</param>
        /// <param name="root">To determine if it should be MaxNode or MinNode</param>
        /// <returns>The new GameNode</returns>
        public GameNode Create(Action a, GameNode root)
        {
            var node = (root is MinNode) ? (GameNode) new MaxNode(a) : new MinNode(a);

            node.m_parent = this;
            return(node);
        }
Пример #2
0
        /**
         * Human plays action a
         */
        public override Status Play(Core.Actions.Action a)
        {
            if (a == null)
            {
                throw new Exception();
            }

            Status status;

            var pm = a as ActionPM;

            if (pm != null)
            {
                status = Human(pm);
            }
            else if (a is Taking)
            {
                status = Human((Taking)a);
            }
            else
            {
                throw new Exception();
                status = Status.INVALIDACTION;
            }
            return(status);
        }
Пример #3
0
        /*
         * Removes now unused subtrees
         * O(n)
         */
        public GameNode RemoveUnusedChilds(Action a)
        {
            var node = Create(a, this);

            m_children.Clear();
            m_children.Enqueue(node);
            return(node);
        }
Пример #4
0
        public GameNode Add(Action a)
        {
            var node = (this is MinNode) ? (GameNode) new MaxNode(a) : new MinNode(a);

            node.m_parent = this;
            m_children.Enqueue(node);
            return(node);
        }
Пример #5
0
        /**
         * Play computer player action
         * @return Status flag
         */
        public override Core.Actions.Action Compute()
        {
            // compute computer player action
            Core.Actions.Action a = m_gameTree.ComputerPlayer();
            if (VERBOSE)
            {
                Debug.WriteLine("Computer has played\n\ttree size: " + m_gameTree.Size());
            }

            // redraw game board: current game tree state is the state after computer played
            Application.Current.Dispatcher.Invoke(() =>
            {
                m_view.UpdateBoard(m_gameTree.CurrentState(), a, true);
            });

            return(a);
        }
Пример #6
0
 /**
  * Create node with action and score
  * @param a Action
  * @param score Score
  */
 public MaxNode(Actions.Action a, int score) : base(a, score)
 {
 }
Пример #7
0
 /**
  * Create node with action
  * @param a Action
  */
 public MaxNode(Actions.Action a) : base(a)
 {
 }
Пример #8
0
 /**
  * Create node with action
  * @param a Action
  */
 public MinNode(Actions.Action a) : base(a)
 {
 }