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 765601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:54:40+00:00 2026-05-14T16:54:40+00:00

Basically I’m creating a forest fire program that depends on the wind / dryness

  • 0

Basically I’m creating a forest fire program that depends on the wind / dryness of the surround elements. I have an array var Trees [,] that is 20 x 20. The middle square is set “on fire”. This is what needs to be done once you click button1: Evaluate each square around the one that is set on fire to determine the probability for the others to catch fire.

Color[,] map = new Color[WIDTH, HEIGHT];
for (int x = 0; x < WIDTH; x++)
    for (int y = 0; y < HEIGHT; y++)
    {
        if (x == WIDTH / 2 && y == HEIGHT / 2)
            map[x, y] = Color.Red;
        else
            map[x, y] = Color.Green;
    }

        fireBox1.box = map;

This is the 20 x 20 array that I have setup with the middle square set on fire. I just have no idea how to get the squares (array elements) around the one that is currently on fire.

  • 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-05-14T16:54:41+00:00Added an answer on May 14, 2026 at 4:54 pm

    You can start with a simple loop.

    for (int i = 0; i < 20; i++)
    {
        for (int j = 0; j < 20; j++)
        {
            var tree = Trees[i, j];
            // ...
        }
    }
    

    After you have built your matrix the center should look like this.

    [G][G][G]
    [G][R][G]
    [G][G][G]
    

    Then we can loop through only the points that touch the center point.

    int centerX = 9;
    int centerY = 9;
    int beginX = centerX - 1; 
    int endX = centerX + 1; 
    int beginY = centerY - 1; 
    int endY = centerY + 1; 
    
    for (int y = beginY; y <= endY; y++)
    {    
        for (int x = beginX ; x <= endX; x++)
        {
            //Skip the center
            if (x == centerX && y == centerY)
                continue;       
            // Calculate the chance of catching on fire.
            if (IsWindyPoint(x, y) || IsDryPoint(x, y))
                map[x, y] = Color.Yellow;
        }
    }
    

    So assuming we have wind blowing east we should see this as the matrix.

    [G][G][G]
    [G][R][Y]
    [G][G][G]
    

    And eventually it will expand out like this.

    [G][G][G][G]
    [G][G][Y][Y]
    [G][R][R][Y]
    [G][G][Y][Y]
    [G][G][G][G]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 404k
  • Answers 404k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried using BOOLEAN MODE search queries? SELECT `user_id`… May 15, 2026 at 5:21 am
  • Editorial Team
    Editorial Team added an answer I don't use freakauth, I just do those things in… May 15, 2026 at 5:21 am
  • Editorial Team
    Editorial Team added an answer [ignore] I notice a leading '/' on your *filePath but… May 15, 2026 at 5:21 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.