Minesweeper Clone - feedback sought

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Minesweeper Clone - feedback sought

Post by nextyoyoma » Thu Oct 17, 2013 7:11 pm

Hi, all. I am helping to teach a LiveCode class, and my students are currently doing a "game" project. I decided to do my own project, so I created a minesweeper clone. It is almost feature-complete; all of the core functionality works, but most visual elements are not yet implemented, and some game options are still hard-coded or set with hidden fields.

I would love to get any feedback anyone can offer on this stack. In particular, I want to resolve/improve two things:

1) Iterative actions take a non-trivial amount of time with a large board

2) With a large board and a small number of mines, it's easy to reach the recursionLimit. This is applicable to the "checkTheTarget" handler.

I am especially looking for feedback on those two issues, but any feedback at all is appreciated. Thanks!

EDIT: It occurs to me that some of you might not want to go to the trouble of downloading and playing with the stack. If you don't have time to do that, take a look at this flood-fill script and tell me what you think, and if I might be able to accomplish the same thing a different way:

Code: Select all

repeat with x = targetx - 1 to targetx + 1
            If x > 0 and x <= rowCount then
               repeat with y = targety - 1 to targety + 1
                  if y > 0 and y <= colCount then
                     checkTheTarget boardArray[x][y],originalTargetID -- this is the name of the handler where this script excerpt is found
                  end if
               end repeat
            end if
         end repeat
This searches all 8 surrounding tiles. I have read a bit about doing this non-recursively in other languages, but I don't know enough about any other languages to make much sense of their solutions.
Attachments
mineTastic.zip
(6.25 KiB) Downloaded 341 times

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 327
Joined: Sun Apr 15, 2012 1:17 am
Location: USA
Contact:

Re: Minesweeper Clone - feedback sought

Post by Newbie4 » Sat Oct 19, 2013 6:16 pm

You are processing the same squares multiple times. Why not create an array to keep track of each square and if it was already checked?

Even better, use the custom property of cUncovered. Check it before calling the handler. If it has already been uncovered, don't "checkTheTarget" again. You may have to keep track of the nesting level (use a global) and do not go deeper than a certain number (2?)

That would be a quick fix without restructuring the code to avoid recursion
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

Post Reply

Return to “Games”