private void ChangedBlackAIStrategy(object sender, SelectionChangedEventArgs e) { try { var aiStrategyText = ((ComboBoxItem)e.AddedItems[0]).Content.ToString(); if (string.IsNullOrEmpty(aiStrategyText)) { _blackAiStrategy = AIStrategies.MostCapturedTiles; } else { _blackAiStrategy = (AIStrategies)Enum.Parse(typeof(AIStrategies), aiStrategyText); } } catch (Exception) { _blackAiStrategy = AIStrategies.MostCapturedTiles; } if (_minMaxBlackPlayer == null || _alfaBetaBlackPlayer == null) { return; } _minMaxBlackPlayer.CurrentStrategy = _blackAiStrategy; _alfaBetaBlackPlayer.CurrentStrategy = _blackAiStrategy; }
/* * this method cannot use GameState, it should be already disposed */ public double GetNiceness(AIStrategies strategy) { switch (strategy) { case AIStrategies.MostCapturedTiles: return(CapturedTiles); case AIStrategies.Mobility: return(PossibleMoves); default: throw new ArgumentOutOfRangeException(nameof(strategy), strategy, null); } }
public MinMaxPlayer(int boardSize, TileStateEnum playerColor, AIStrategies strategy, int searchDepth = 4) { _currentBoardState = new TileStateEnum[boardSize][]; for (var i = 0; i < _currentBoardState.Length; i++) { _currentBoardState[i] = new TileStateEnum[boardSize]; for (var j = 0; j < _currentBoardState[i].Length; j++) { _currentBoardState[i][j] = TileStateEnum.Empty; } } _playerColor = playerColor; _searchDepth = searchDepth; CurrentStrategy = strategy; }