1 Replies - 600 Views - Last Post: 04 November 2009 - 12:48 AM Rate Topic: -----

#1 Yummy90  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-October 09

Anyone know how to Clear the adjacent square in one go in minesweeper

Posted 03 November 2009 - 11:30 PM

I dunno how to clear the blank square in one go..... so far i have did this....
Anyone know how to do?

int e,f,g=0;
	if(action=='C')
	{
		
		/*** Checking whether the square already opened before or not ***/
		if (Board[InitPox][InitPoy].open == 0)	  /* If the square has not been opened yet */
		{
			Beep(500,200);
			printf ("The square is opened! ^^/> \n\n");
			
			
			/*** Display the number of mine on the square if the square is adjacent to the location of mine ***/
			for (e=-1;e<2;e++)
			{
				for (f=-1;f<2;f++)
				{
					if (Mines[InitPox + e][InitPoy + f].mine == '*')
					{
						g++;
					}
					
					else
					if (Mines[InitPox + e][InitPoy +f].mine == ' ')
					
					for (e=-1;e<2;e++)
					{
						for (f=-1;f<2;f++)
						{
							if (Mines[e][f].mine == ' ')
							printf("%i",Board[e][f].numMines);
						}
					}
					
					if(Mines[InitPox][InitPoy].mine == '*')
					{
					
						Beep(900,200);
						Beep(700,200);
						Beep(500,200);
						printf ("Boom! Your turtle is dead...\n\n");
						printf ("****** Game Over! You Lose ! ******\n");
						displayReveal(Board,Mines);
						exit (1);
					}
				}	 
			}
			
			Board[InitPox][InitPoy].numMines = g;
		}
		
		
		if (Board[InitPox][InitPoy].open == 1)	  /* If the square has been opened before */
		{
			printf ("The square already opened ! \n\n");
		}
		
		Board[InitPox][InitPoy].open = 1;
	}
	
}  /* end of ClearSq() */	  


Is This A Good Question/Topic? 0
  • +

Replies To: Anyone know how to Clear the adjacent square in one go in minesweeper

#2 gronk  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 168
  • Joined: 28-October 09

Re: Anyone know how to Clear the adjacent square in one go in minesweeper

Posted 04 November 2009 - 12:48 AM

Looking at the code it seems you haven't tried anything yet for clearing all the blank squares. What's your algorithm for doing that? You could use either iteration or recursion, but you will need to decide how it'll work before you can write the code for it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1