public void CreatePlayers(int gameMode) { Player player1 = new RealPlayer(); Player player2 = new RealPlayer(); Player randomAi = new RandomAI(); Player smartAi = new SmartAI(); currentTurn = player1; switch (gameMode) { case 0: players.Add(player1); players.Add(player2); break; case 1: players.Add(player1); players.Add(smartAi); break; case 2: currentTurn = randomAi; players.Add(randomAi); players.Add(smartAi); break; } }
public void StoreCriticalMoves() { if (numComputerPlayers == 1) { if (turn == Player.Player1) { BoardState losingState = boardStates[(boardStates.Count - 3)]; // third from last move, the move that led to the win/loss losingState.MoveValue += -1; if (player2.GetType().Equals(typeof(SmartAI))) { SmartAI AI = player2 as SmartAI; AI.AddCriticalMove(losingState); } } else if (turn == Player.Player2) { BoardState losingState = boardStates[(boardStates.Count - 3)]; // third from last move, the move that led to the win/loss losingState.MoveValue += 1; if (player2.GetType().Equals(typeof(SmartAI))) { SmartAI AI = player2 as SmartAI; AI.AddCriticalMove(losingState); } } } else if (numComputerPlayers == 2) { if (turn == Player.Player1) // Comp stores last critical move { BoardState losingState = boardStates[(boardStates.Count - 3)]; losingState.MoveValue += -1; if (player2.GetType().Equals(typeof(SmartAI))) { SmartAI AI = player2 as SmartAI; AI.AddCriticalMove(losingState); } } else if (turn == Player.Player2) // if the winner is player 2, comp 1 stores the losing move { BoardState losingState = boardStates[(boardStates.Count - 3)]; losingState.MoveValue += 1; if (player2.GetType().Equals(typeof(SmartAI))) { SmartAI AI = player2 as SmartAI; AI.AddCriticalMove(losingState); } } } }