public NodeGameState(POGame.POGame poGame, PlayerTask task = null, NodeGameState parent = null) { chdr = new List <NodeGameState>(); prt = parent; game = poGame.getCopy(); this.task = task; WasExpanded = false; PlayerId = game.CurrentPlayer.PlayerId; if (parent == null) { isEnemyNode = false; // root is always MyPlayer } else if (PlayerId != parent.PlayerId) { isEnemyNode = !parent.isEnemyNode; } else { isEnemyNode = parent.isEnemyNode; } }
public PlayerTask GetMoveSearchTree(POGame.POGame poGame, int depth) { if (poGame.CurrentPlayer.Options().Count == 1) { return(poGame.CurrentPlayer.Options().First()); } else if (poGame.CurrentPlayer.Options().Count == 2) { return(poGame.CurrentPlayer.Options()[1]); } else { if (ListPlayerTasksToDo.Count == 0) { ListPlayerTasksToDo = new Queue <PlayerTask>(); var root = new NodeGameState(poGame); root.IDDFS(depth); ListPlayerTasksToDo = root.GetPlayerTasks(); } return(ListPlayerTasksToDo.Dequeue()); } }
private Queue <PlayerTask> GetPlayerTasksMinimax() { var que = new Queue <PlayerTask>(); if (!IsRoot) { que.Enqueue(task); } if (!IsLeaf) { IOrderedEnumerable <NodeGameState> orderedChildren = chdr.OrderByDescending(p => p.score); //Min if true, Max if false NodeGameState nextNode = isEnemyNode ? orderedChildren.Last() : orderedChildren.First(); Queue <PlayerTask> queueTail = nextNode.GetPlayerTasksMinimax(); while (queueTail.Count > 0) { que.Enqueue(queueTail.Dequeue()); } } return(que); }