public Engine(List<Player> inputPlayers, int sizeGameField) { this.players = inputPlayers; //We could make multiplayer for more than 2 players, logic will not be much different this.numberOfPlayers = inputPlayers.Count; //The Game starts from the first player in the input List this.indexCurrentPlayer = 0; //We could make game fields with different sizes this.area = new GameField.Field(); //Checking how many human players are going to play int tempNumberOfHumanPLayers = 0; foreach (Player player in players) { if (player is HumanPlayer) { ++tempNumberOfHumanPLayers; } } this.numberOfHumanPlayers = tempNumberOfHumanPLayers; ////If the AI is first //if (players[0] is AIPlayer) //{ // PlayAITurn(); //} }
public object Clone() { Field result = new Field(this.size); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { result[i, j] = this[i, j]; } } return result; }
//Make a decision for the next move based on the input field public int MakeDecision(Field inputField) { gameField = inputField; //Used to store the moves that can be done, starting from teh most important SortedDictionary<int, int> actions = new SortedDictionary<int, int>(); //For each configuration check how many free, my and enemy cells are there CheckRows(actions); CheckColumns(actions); CheckDiagonals(actions); return TakeBestAction(actions); }