Thread: Minesweeper Recursion

  1. #1
    Deleted Account
    Join Date
    Mar 2005
    Posts
    57

    Minesweeper Recursion

    I'm up to my last part of my assignment for uni, i thought i had done it all correctly until i found out i hadn't (i've never played minesweeper before ).. anywayz, i'm doing my function for "uncover".

    Say if u uncover a blank square, this means all adjacent sqaures will be uncovered, and those adjacent squares with their adjcanet squares will be uncovered etc if blank, or something alone those lines. the thing is i'm having some trouble in starting it, cud someone help maybe explaing in some simple steps to help me get started.....

    btw, the function called wud have something like

    recuriveUncover(minefield[][], displayGrid[][], row, col, size)

    where minefield is the array with all the information, and displayGrid is the info being revealed while playing the game.

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    155
    a function gets the adjacent blocks and determines whether the blocks r all empty.
    store these adjacent postions in struct array(x,y) .
    give recursive calls to this function on a loop which starts checking each struct array(x,y) member.
    Last edited by qqqqxxxx; 03-21-2006 at 06:08 AM.

  3. #3
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    Check each neighbouring square for their status. If a square is blank and not uncovered set it's status to uncovered and call the function on that square (the recursion takes place here).
    When all surrounding squares are either numeral (uncovered or not) or uncovered blanks the function ends.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Template Recursion Pickle
    By SevenThunders in forum C++ Programming
    Replies: 20
    Last Post: 02-05-2009, 09:45 PM
  2. Recursion... why?
    By swgh in forum C++ Programming
    Replies: 4
    Last Post: 06-09-2008, 09:37 AM
  3. a simple recursion question
    By tetra in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 10:56 AM
  4. To Recur(sion) or to Iterate?That is the question
    By jasrajva in forum C Programming
    Replies: 4
    Last Post: 11-07-2001, 09:24 AM
  5. selection sorting using going-down and going-up recursion
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-02-2001, 02:29 PM