Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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());
        }