Пример #1
0
        public static Board GetNewBoard()
        {
            Board board = new Board();

            board._unplayedPieces.Add(new QueenBee(PieceColor.White, 1));
            board._unplayedPieces.Add(new Beetle(PieceColor.White, 1));
            board._unplayedPieces.Add(new Beetle(PieceColor.White, 2));
            board._unplayedPieces.Add(new Spider(PieceColor.White, 1));
            board._unplayedPieces.Add(new Spider(PieceColor.White, 2));
            board._unplayedPieces.Add(new Hopper(PieceColor.White, 1));
            board._unplayedPieces.Add(new Hopper(PieceColor.White, 2));
            board._unplayedPieces.Add(new Hopper(PieceColor.White, 3));
            board._unplayedPieces.Add(new Ant(PieceColor.White, 1));
            board._unplayedPieces.Add(new Ant(PieceColor.White, 2));
            board._unplayedPieces.Add(new Ant(PieceColor.White, 3));

            board._unplayedPieces.Add(new QueenBee(PieceColor.Black, 1));
            board._unplayedPieces.Add(new Beetle(PieceColor.Black, 1));
            board._unplayedPieces.Add(new Beetle(PieceColor.Black, 2));
            board._unplayedPieces.Add(new Spider(PieceColor.Black, 1));
            board._unplayedPieces.Add(new Spider(PieceColor.Black, 2));
            board._unplayedPieces.Add(new Hopper(PieceColor.Black, 1));
            board._unplayedPieces.Add(new Hopper(PieceColor.Black, 2));
            board._unplayedPieces.Add(new Hopper(PieceColor.Black, 3));
            board._unplayedPieces.Add(new Ant(PieceColor.Black, 1));
            board._unplayedPieces.Add(new Ant(PieceColor.Black, 2));
            board._unplayedPieces.Add(new Ant(PieceColor.Black, 3));
            board._hivailableHexes.Add(new Hex(24, 24), Hivailability.GetHivailability(board, new Hex(24, 24), true));
            return(board);
        }
Пример #2
0
        private void RefreshAllHivailability(bool forceBlackCanPlace = false)
        {
            _hivailableHexes.Clear();
            foreach (Hex hex in _playedPieces.Values)
            {
                foreach (Hex directionHex in Neighborhood.neighborDirections)
                {
                    // don't do the center
                    if (directionHex.Equals(new Hex(0, 0)))
                    {
                        continue;
                    }

                    Hex   adjacentHex = hex + directionHex;
                    Piece adjacentPiece;
                    if (!TryGetPieceAtHex(adjacentHex, out adjacentPiece))
                    {
                        // empty space, add/update hivailability
                        if (!_hivailableHexes.ContainsKey(adjacentHex))
                        {
                            _hivailableHexes.Add(adjacentHex, Hivailability.GetHivailability(this, adjacentHex, false, forceBlackCanPlace));
                        }
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// returns the number of empty neighbors for a piece on the board
        /// returns .int.MaxValue if the given piece is unplayed
        /// </summary>
        /// <param name="piece"></param>
        /// <returns></returns>
        public int BreathingSpaces(Piece piece)
        {
            Hex hex;

            if (TryGetHexOfPlayedPiece(piece, out hex))
            {
                var hivailability = Hivailability.GetHivailability(this, hex);
                return(hivailability.EmptyNeighborHexes(hex).Count);
            }
            else
            {
                return(6);
            }
        }