public MatrixPlayer(int playerNumber, int boardSize, Config playerConfig) : base(playerNumber, boardSize, playerConfig) { Size = boardSize; PlayerNumber = playerNumber; Me = PlayerNumber == 1 ? Players.PlayerType.Blue : Players.PlayerType.Red; MaxLevels = GetDefault(playerConfig, "maxLevels", 20); Name = playerConfig.name; Board = new MatrixHex[Size, Size]; for (int row = 0; row < Size; row++) { for (int col = 0; col < Size; col++) { Board[row, col] = new MatrixHex(Size); } } MyMoves = Matrix <int> .Build.Dense(Size, Size); MyMoves.Clear(); EnemyMoves = Matrix <int> .Build.Dense(Size, Size); EnemyMoves.Clear(); //Startup(); }
public override Tuple <int, int> SelectHex(Tuple <int, int> opponentMove) { UpdateEnemyMoves(opponentMove); // Now that we've updated the player information, time to look for a move. var matrixToExamine = MyMoves .Add(EmptyMatrix.Multiply(2)) .Add(EnemyMoves.Multiply(3)); var bestScore = Minimax(matrixToExamine, MaxLevels, AbsoluteWorstScore, AbsoluteBestScore, true); return(null); }
public int CostOfBestPath(Matrix <int> board, PlayerType player) { var vertical = MyMoves.RowSums(); var horizontal = MyMoves.ColumnSums(); var emptyVertical = Enumerable.Count <int>(vertical, x => x.Equals(0)); var emptyHorizontal = Enumerable.Count <int>(horizontal, x => x.Equals(0)); if (Me == Players.PlayerType.Blue) { return(1); } return((Size - emptyVertical) + (Size - emptyHorizontal)); }
public override List <Move> GetNextMove() { if (!_nextX.HasValue || !_nextZ.HasValue) { return(new List <Move>()); } LogicalPiece selected = new LogicalPiece(_nextX.Value, _nextZ.Value, Color); _nextX = null; _nextZ = null; // This is a bold assumption: For we check if the field exists in the tile, we know that we should only // get selected pieces that are actually in the set of potentialMoves return(MyMoves .Where(move => move.Played.Equals(selected)) .ToList()); }