コード例 #1
0
        private bool WillBreakHive(ITile piece)
        {
            if (HexCoordinates.Count == 1)
            {
                return(true);
            }

            var boardWithoutPiece = this.HexCoordinates.ToDictionary(d => d.Key, d => d.Value);

            boardWithoutPiece.Remove(piece.Location.GetHashCode());

            ITile firstNeighbor = null;

            for (int i = 0; i < 6; i++)
            {
                var neighbor = piece.Location.Neighbor(i);
                if (boardWithoutPiece.ContainsKey(neighbor.GetHashCode()))
                {
                    firstNeighbor = boardWithoutPiece[neighbor.GetHashCode()];
                }
            }

            if (firstNeighbor == null)
            {
                return(false);
            }

            return(!BreadthFirstSearch.CheckSingleHive(boardWithoutPiece, firstNeighbor));


            //SECOND IDEA IS SEEING IF THERE IS A NEIGHBOR SURROUNDED BY TWO EMPTY SPACES AND SEEING IF WE CAN RECURSIVELY GET BACK TO THAT NEIGHBOR FROM A DIFFERENT ONE

            //Get non empty neighbors. add to list and create a bad list.

            //Loop through non empty neighbors.

            ////if neighbor is not surrounded by empties, remove from bad list.

            ////If neighbor is piece surrounded by empties, do a search for other neighbors with piece removed

            //////If other neighbor not found, return true.

            //////If other neighbor found remove from list.

            //if problem list is empty then return false;
        }