minesweeper...

This is a discussion on minesweeper... within the C Programming forums, part of the General Programming Boards category; how can I make a function to calculate number of mines near by? I wrote as this.. but it does ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    32

    minesweeper...

    how can I make a function to calculate number of mines near by?
    I wrote as this.. but it does not work properly.

    Code:
    int calculate()
    {
    int sum = 0;
    int i;
    int j;
    
    for(i=0; i<9; i++)
         for (j=0; j<9; j++)
          if (mines[i][j] != "*" )
          {
               if(mines[i+1][j] = "*");
               {
               sum = 1 + calculate ();
                }
                          else if(mines[i+1][j+1] = "*");
                            {
                            sum = 1 + calculate ();
                             }
                             else if(mines[i+1][j] = "*");
                                    {
                                sum = 1 + calculate ();
                                   }
                else if(mines[i+1][j-1] = "*");
                                 {
                               sum = 1 + calculate ();
                             }
                 else if(mines[i][j-1] = "*");
                           {
                              sum = 1 + calculate ();
                              }
                      else if(mines[i-1][j-1] = "*");
                               {
                               sum = 1 + calculate ();
                               }
                            else if(mines[i-1][j] = "*");
                                      {
                                        sum = 1 + calculate ();
                                           }
                                   else(mines[i-1][j+1] = "*");
                                          {
                                               sum = 1 + calculate ();
                                              }
    
          return sum;
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) Use = for assignment and == for comparison.
    2) Use " " for strings and ' ' for single characters.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's the best way to draw a minesweeper field
    By Nazgulled in forum C Programming
    Replies: 1
    Last Post: 05-08-2007, 01:24 PM
  2. AI Contest - Minesweeper
    By Darryl in forum Contests Board
    Replies: 93
    Last Post: 04-24-2006, 05:48 PM
  3. minesweeper
    By sameintheend01 in forum C++ Programming
    Replies: 1
    Last Post: 02-18-2003, 08:50 AM
  4. minesweeper problem
    By adamrobbie in forum C Programming
    Replies: 2
    Last Post: 10-14-2002, 08:03 PM
  5. Home made Minesweeper using SDL
    By damyan in forum Game Programming
    Replies: 3
    Last Post: 11-02-2001, 05:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21