コード例 #1
0
    protected override void CheckingNewRevealed(Vector2Int currentnewrevealed)
    {
        //count the number of neighbores of this tile
        List <Vector2Int> newClosedHiddenNeighbors = new List <Vector2Int>();

        ClosedHiddenNeighbores.Add(currentnewrevealed, newClosedHiddenNeighbors);

        for (int j = 0; j < Operators.Length; j++)
        {
            Vector2Int current = currentnewrevealed + Operators[j];
            if (Flaged.Contains(current))
            {
                Closed[currentnewrevealed]--;
            }
            else if (MinesweeperElementInfo.InBounds(current, BoardSize.x, BoardSize.y))
            {
                if (Open.ContainsKey(current) || Safe.Contains(current) || Mine.Contains(current))
                {
                    newClosedHiddenNeighbors.Add(current);
                    List <Vector2Int> clist = HiddenClosedRelations[current];
                    clist.Add(currentnewrevealed);
                }
                else if (!InvalidTiles[current.x, current.y] && !Closed.ContainsKey(current))
                {
                    Open.Add(current, 0);
                    newClosedHiddenNeighbors.Add(current);
                    List <Vector2Int> clist = new List <Vector2Int>();
                    HiddenClosedRelations.Add(current, clist);
                    clist.Add(currentnewrevealed);
                }
            }
        }
    }
コード例 #2
0
 /// <summary>
 /// Iterates through 'currentnewrevealed', checking if 'currentnewrevealed' can be discarded,
 /// while adding new open tile
 /// </summary>
 /// <param name="currentnewrevealed"></param>
 protected virtual void CheckingNewRevealed(Vector2Int currentnewrevealed)
 {
     for (int j = 0; j < Operators.Length; j++)
     {
         Vector2Int current = currentnewrevealed + Operators[j];
         if (Flaged.Contains(current))
         {
             Closed[currentnewrevealed]--;
         }
         else if (MinesweeperElementInfo.InBounds(current, BoardSize.x, BoardSize.y))
         {
             //i wanted to make the minesweeper and the solver independent from eachother, thats why i didn't simply passed the minesweeperelementinfo object at 'current' tile
             if (!InvalidTiles[current.x, current.y] && !Open.ContainsKey(current) && !Closed.ContainsKey(current) && !Safe.Contains(current) && !Mine.Contains(current))
             {
                 Open.Add(current, 0);
             }
         }
     }
 }