Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8993583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:13:25+00:00 2026-06-15T23:13:25+00:00

I am currently making a Minesweeper clone. I made an algorithm that, when clicked

  • 0

I am currently making a Minesweeper clone.
I made an algorithm that, when clicked on a tile with 0 surrounding mines, reveals all neighbors with 0 surrounding mines then all neighbors of them with 0 surrounding mines… (recursion).
This result only needs one click:

It works like it should but it is too slow. The original Minesweeper reveals these tiles instantly, but in my case, they have a little delay between the reveals.

I wrote this code:

private void RevealNeighbor(int x, int y) {
    foreach(var neighbor in _neighbors) {
        try {
            Tile tile = _tiles[x + neighbor[0], y + neighbor[1]];
            if(tile.TileType == TileType.Empty && tile.Hidden) {
                tile.Reveal();
                if(tile.Number == 0) {
                    RevealNeighbor(x + neighbor[0], y + neighbor[1]);
                }
            }
        }
        catch(IndexOutOfRangeException) {
        }
    }
}

_neighbors is an array of arrays, that has the 8 position offsets for the neighbors:

private readonly int[][] _neighbors = new[] {
                                          new[] {-1, -1},
                                          new[] {0, -1},
                                          new[] {1, -1},
                                          new[] {1, 0},
                                          new[] {1, 1},
                                          new[] {0, 1},
                                          new[] {-1, 1},
                                          new[] {-1, 0}
                                      };

How can I make it faster?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:13:26+00:00Added an answer on June 15, 2026 at 11:13 pm

    Use the SuspendLayout method, to draw only when needed:

    *false is a default for the designer, find out what it means

    this.SuspendLayout();
    ... logic      
    this.ResumeLayout(false);
    

    ALSO – avoid abusing the Exceptions mechanism, it is not efficient and bad practice

    instead use a wall (extra tile on the end of the matrix indicating.. well.. a wall).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently making a program that will send an email if the date
Im currently making a firefox extension that will let you choose what tabs you
I am currently making an app that will have multiple timers, which are basically
I am currently making a tiny script that tags cordenades in an array: var
I am currently making a Facebook application for iOS that pulls the profile feed
I am currently making a rails app that will search #barcampmlk2 #{thesessionname} +1 from
I'm currently making a word game for iOS that, when loading, reads in a
I am currently making our website to be supported by all major browsers and
I'm making a class so I can cheat at minesweeper, and is currently building
Currently making apps [html5/js] that run through various platforms that make use of UIWebView,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.