//public void Options(ref Dictionary<string, OptionNode> optionNodes) //{ // var options = _game.ControllerById(_playerId).Options(!_isOpponentTurn); // foreach (var option in options) // { // var optionNode = new OptionNode(this, _game, _playerId, option, Scoring); // if (!optionNodes.ContainsKey(optionNode.Hash)) // optionNodes.Add(optionNode.Hash, optionNode); // } //} public void Options(ref ConcurrentDictionary <string, OptionNode> optionNodes) { List <PlayerTask> options = _game.ControllerById(_playerId).Options(/*!_isOpponentTurn*/); foreach (PlayerTask option in options) { var optionNode = new OptionNode(this, _game, _playerId, option, Scoring); optionNodes.TryAdd(optionNode.Hash, optionNode); } }
public void Options(ref Dictionary <string, OptionNode> optionNodes) { var options = _game.ControllerById(_playerId).Options(!_isOpponentTurn); foreach (var option in options) { var optionNode = new OptionNode(this, _game, _playerId, option, Scoring); if (!optionNodes.ContainsKey(optionNode.Hash)) { optionNodes.Add(optionNode.Hash, optionNode); } } }
public OptionNode(OptionNode parent, Game game, int playerId, PlayerTask playerTask, IScore scoring) { _parent = parent; _game = game.Clone(); // create clone _playerId = playerId; PlayerTask = playerTask; Scoring = scoring; if (!IsRoot) { Execute(); } }