示例#1
0
        // sets the tile as a mine, stores it for future use and returns true if it is currently flagged
        public bool MineFound(SolverTile tile)
        {
            // if this is already known to be mine then nothing to do
            if (tile.IsMine())
            {
                return(tile.IsFlagged());
            }

            tilesLeft--;

            tile.SetAsMine(key);

            knownMines.Add(tile);

            if (tile.IsDead())
            {
                deadTiles.Remove(tile);  // remove the tile if it was on the dead list
            }
            //if (tile.IsExcluded()) {
            //    excludedTiles.Remove(tile); // remove the tile if it was excluded
            //   excludedMinesCount--;
            //}

            return(tile.IsFlagged());
        }
示例#2
0
        // returns the probability the tile is safe if known. Or -1 otherwise.
        public double GetProbability(int x, int y)
        {
            // if we are out of bounds then nothing to say
            if (x < 0 || x >= description.width || y < 0 || y >= description.height)
            {
                return(-1);
            }

            SolverTile tile = tiles[x, y];

            // an unflagged mine
            if (tile.IsMine() && !tile.IsFlagged())
            {
                return(0);
            }

            // otherwise if revealed then nothing to say
            if (!tile.IsHidden())
            {
                return(-1);
            }

            //if (tile.IsExcluded()) {
            //    return -1;
            //}

            if (probabilityEngine != null)
            {
                return(probabilityEngine.GetProbability(tile));
            }
            else if (pendingClears.Contains(tile))
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }