/// <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); }
/** * 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); }
/* * 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); }
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); }
/** * 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); }
/** * Create node with action and score * @param a Action * @param score Score */ public MaxNode(Actions.Action a, int score) : base(a, score) { }
/** * Create node with action * @param a Action */ public MaxNode(Actions.Action a) : base(a) { }
/** * Create node with action * @param a Action */ public MinNode(Actions.Action a) : base(a) { }