private async Task HandleAITurn(IAIPlayer currentAI, IPlayer nextAI) { if (!currentAI.FoldedTurn) { if (currentAI.IsInTurn) { this.FixCall(currentAI);//, 1); //this.FixCall(currentAI, 2); this.MessageWriter.Write(string.Format(Messages.PlayerTurn, currentAI.Name)); currentAI.ProccessNextTurn(Call, this.Pot, ref raise, ref isAnyPlayerRaise, this.dealer.CurrentRound); this.turnCount++; currentAI.IsInTurn = false; nextAI.IsInTurn = true; } } if (currentAI.FoldedTurn && !currentAI.HasFolded) { currentAI.HasFolded = true; } if (currentAI.FoldedTurn || !currentAI.IsInTurn) { await this.CheckRaise(currentAI.Id + 1); // , currentAI.Id + 1); nextAI.IsInTurn = true; } }
public void GameStart(IAIPlayer player, int difficulty) { // Initiate path, route and slidingDirection. path = new List <PlayerAction>(); route = new Stack <Point>(); slidingDirection = new Point(); this.player = player; // Assign the tileField, and create the visited array with the right dimensions. tileField = this.player.DummyPlayer.TileField; visited = new bool[tileField.Columns, tileField.Rows, 128, 4]; // Start the FloodFill algorithm. Flood(player.DummyPlayer.Location, 0, 0); // Turn the route into a list of actions for UpdateNextAction(). RouteToPath(route); }
private const int aiDelay = 250; // The time for an AI player play public BoardViewModel(GameManager gameManager) { if (gameManager == null) { throw new ArgumentNullException(); } this.gameManager = gameManager; gameManager.GameChanged += OnGameCanged; player1 = new HumanPlayerViewModel(gameManager, 0); player2 = new PlayerViewModel(gameManager, 1); player3 = new PlayerViewModel(gameManager, 2); player4 = new PlayerViewModel(gameManager, 3); aiPlayer = new SimpleAIPlayer(); Update(); }
private ICollection <IAIPlayer> GetEnemies(IAILogicProvider logicProvider) { IAIPlayer AI1 = PlayerFactory.CreateAI(logicProvider, AppSettigns.SecondPlayerName, AppSettigns.DefaultChipsCount, this.labelBot1Status, this.textboxBot1Chips, AppSettigns.SecondPlayerAnchorStyles, AppSettigns.SecondPlayerPictureBoxX, AppSettigns.SecondPlayerPictureBoxY); IAIPlayer AI2 = PlayerFactory.CreateAI(logicProvider, AppSettigns.ThirdPlayerName, AppSettigns.DefaultChipsCount, this.labelBot2Status, this.textboxBot2Chips, AppSettigns.ThirdPlayerAnchorStyles, AppSettigns.ThirdPlayerPictureBoxX, AppSettigns.ThirdPlayerPictureBoxY); IAIPlayer AI3 = PlayerFactory.CreateAI(logicProvider, AppSettigns.FourthPlayerName, AppSettigns.DefaultChipsCount, this.labelBot3Status, this.textboxBot3Chips, AppSettigns.FourthPlayerAnchorStyles, AppSettigns.FourthPlayerPictureBoxX, AppSettigns.FourthPlayerPictureBoxY); IAIPlayer AI4 = PlayerFactory.CreateAI(logicProvider, AppSettigns.FifthPlayerName, AppSettigns.DefaultChipsCount, this.labelBot4Status, this.textboxBot4Chips, AppSettigns.FifthPlayerAnchorStyles, AppSettigns.FifthPlayerPictureBoxX, AppSettigns.FifthPlayerPictureBoxY); IAIPlayer AI5 = PlayerFactory.CreateAI(logicProvider, AppSettigns.SixthPlayerName, AppSettigns.DefaultChipsCount, this.labelBot5Status, this.textboxBot5Chips, AppSettigns.SixthPlayerAnchorStyles, AppSettigns.SixthPlayerPictureBoxX, AppSettigns.SixthPlayerPictureBoxY); ICollection <IAIPlayer> enemies = new List <IAIPlayer>() { AI1, AI2, AI3, AI4, AI5 }; foreach (var enemy in enemies) { this.AddPlayerUIComponents(enemy); } return(enemies); }
static void Main(string[] args) { int vittorieA = 0; int vittorieB = 0; int parita = 0; //while (true) //{ ITavola tavola = new Tavola(); IPlayer p1 = new MinMaxAlphaBeta(4, new HeuristicFunctionValue(Lato.A)); IPlayer p2 = new MinMaxAlphaBetaWithOpen(4, new HeuristicFunctionValue(Lato.B)); //IPlayer p2 = new MinMaxPlayer(Convert.ToInt32(args[0])); IGioco gioco = new Gioco(tavola); Bant bantumi = new Bant(gioco, p1, p2); //gioco.Start(); Render(gioco.Tavola); Console.WriteLine("Muove Player" + gioco.ProssimoTurno); Thread.Sleep(sleepTime); while (gioco.Vincitore == null && !gioco.Parita) { IPlayer player = bantumi.GetPlayer(gioco.ProssimoTurno); if (player is HumanPlayer) { if (gioco.ProssimoTurno == Lato.A) { Console.WriteLine("Player" + Lato.A + " scegli una buca fra 0 e 5"); } else { Console.WriteLine("Player" + Lato.B + " scegli una buca fra 7 e 12"); } gioco.Muovi(ReadValue(gioco)); } else { if (player is IAIPlayer) { IAIPlayer aiPlayer = player as IAIPlayer; int i = aiPlayer.Elaborazione(gioco); Console.WriteLine("MUOVE" + i); gioco.Muovi(i); } } Render(gioco.Tavola); Thread.Sleep(sleepTime); } if (gioco.Parita) { Console.WriteLine("Parità"); parita++; } else { if (gioco.Vincitore == Lato.A.ToString()) { Console.WriteLine("Ha vinto Player" + gioco.Vincitore); Console.ReadLine(); //vittorieA++; } if (gioco.Vincitore == Lato.B.ToString()) { Console.WriteLine("Ha vinto Player" + gioco.Vincitore); Console.ReadLine(); //vittorieB++; } } //} }
public MainWindowViewModel(IAIPlayer aiPlayer, IGameChecker gameChecker) { _pendingPlayerAction = true; _aiPlayer = aiPlayer; _gameChecker = gameChecker; }
public void GameStart(IAIPlayer player, int difficulty) { this.player = player; }
public void GameStart(IAIPlayer player, int difficulty) { this.player = player; path = FindPath(); }
private void InitializeAiPlayer(ChessboardType chessboardType, UserType userType) { aiPlayer = AiPlayerProvider.GetAiPlayer(chessboardType, userType); }