public override TurnChoice GetTurn(GameState gameState) { List <TurnChoice> choices = GetValidTurnChoices(gameState.whitePlayer.pos); List <GameState> successors = gameState.GetSuccessors(choices, false); int g = 0; int best = successors[0].MiniMax(true); for (int i = 0; i < successors.Count; i++) { int current = successors[i].MiniMax(true); if (current < best) { g = i; } } TurnChoice turn = choices[g]; //Apply changes of this turn to player variables pos = pos.GetNewPosition(turn.direction, turn.movementNr); cards.Remove(turn.actionCard); movement[turn.movementNr - 1] = false; Console.Write("Computer plays {0} with movement {1} going {2}", turn.actionCard.type, turn.movementNr, turn.direction); if (turn.actionCard.type == Card.Type.MerchantsBribe) { Console.Write(" with aim direction " + turn.aimDirection); } Console.WriteLine(""); return(turn); }
//Get the player's turn as a TurnChoice object public override TurnChoice GetTurn(GameState gameState) { Board board = gameState.board; Console.WriteLine("--------------------------------------------------"); Console.WriteLine("It's your turn, pick an Action Card"); WriteCardChoice(cards); int aChoice = GetIntChoice(0, cards.Count - 1); Card a = cards[aChoice]; Console.WriteLine("You picked: " + cards[aChoice].type); cards.RemoveAt(aChoice); WriteMovementChoice(); int m = GetMovementChoice(); Console.WriteLine("You picked Movement " + m); movement[m - 1] = false; Direction dir = GetDirectionChoice(true, m, board); TurnChoice turnChoice = new TurnChoice(a, m, dir, pos, true); if (a.type == Card.Type.MerchantsBribe) { Direction aimDir = GetDirectionChoice(false, m, board); turnChoice = new TurnChoice(a, m, dir, pos, true, aimDir); } Console.Write("You play {0} with movement {1} going {2}", a.type, m, dir); if (a.type == Card.Type.MerchantsBribe) { Console.Write(" with aim direction " + turnChoice.aimDirection); } Console.WriteLine(""); Console.WriteLine("------------------"); pos = pos.GetNewPosition(turnChoice.direction, turnChoice.movementNr); return(turnChoice); }
//Get the next turn and play its effects out on the board public void UpdateBoard(TurnChoice turn) { Position newPos = turn.startPos; //If it's the white monk if (turn.isWhite) { tiles[turn.startPos.X, turn.startPos.Y].monk_W = false; newPos = turn.startPos.GetNewPosition(turn.direction, turn.movementNr); tiles[newPos.X, newPos.Y].monk_W = true; whitePos = newPos; } //If it's the black monk else { tiles[turn.startPos.X, turn.startPos.Y].monk_B = false; newPos = turn.startPos.GetNewPosition(turn.direction, turn.movementNr); tiles[newPos.X, newPos.Y].monk_B = true; blackPos = newPos; } switch (turn.actionCard.type) { case Card.Type.SpreadInfluence: DoSpreadInfluence(turn.isWhite, newPos); break; case Card.Type.PathOfFaith: DoPathOfFaith(turn.isWhite, turn.startPos, newPos); break; case Card.Type.Disciple: DoDisciple(turn.isWhite, newPos); break; case Card.Type.ActOfViolence: DoActOfViolence(turn.isWhite, newPos); break; case Card.Type.PreachDistrust: DoPreachDistrust(turn.isWhite, newPos, turn.direction); break; case Card.Type.MerchantsBribe: DoMerchantsBribe(turn.isWhite, newPos, turn.aimDirection); break; default: break; } UpdateCounters(); }
private GameState GetNewGameState(TurnChoice tc) { GameState successor = new GameState(whitePlayer, blackPlayer, board); if (tc.isWhite) { successor.whitePlayer.cards.Remove(tc.actionCard); successor.whitePlayer.movement[tc.movementNr - 1] = false; successor.whitePlayer.pos = whitePlayer.pos.GetNewPosition(tc.direction, tc.movementNr); successor.board.UpdateBoard(tc); } else { successor.blackPlayer.cards.Remove(tc.actionCard); successor.blackPlayer.movement[tc.movementNr - 1] = false; successor.blackPlayer.pos = blackPlayer.pos.GetNewPosition(tc.direction, tc.movementNr); successor.board.UpdateBoard(tc); } return(successor); }