Please help! how can I fix the no more move situations.

Discussion in 'Public Game Developers Forum' started by songkranw, May 3, 2013.

  1. songkranw

    songkranw Well-Known Member

    Hi I'm the creater of the Running From The Dead a buggy match-3 zombie survival rpg game.

    The game is play like DungeonRaid.

    What should I do when there come a situation where thereis no three match available on screen?

    Currently I have a trouble detecting when this is happen.

    Any suggestion on detecting the event or way to prevent it.

    Thank.
     
  2. AlienSpace

    AlienSpace Well-Known Member

    May 28, 2010
    416
    0
    16
    Independent developer
  3. songkranw

    songkranw Well-Known Member

    Thank you! going there now.
     
  4. mr.Ugly

    mr.Ugly Well-Known Member

    Dec 1, 2009
    1,673
    0
    36
    Berlin, Germany
    #4 mr.Ugly, May 3, 2013
    Last edited: May 3, 2013
    well preventing is detecting

    the "simplest" way would be to "brute force" all possible chained iterations through your grid, cell by cell.

    if its a chain match 3+ like dungeon raid your worst case per cell is a check against its surrounding 5x5 grid where the startpoint is the middle of the field.

    if you can go diagonal like DR there can be alot of possible chains to check per starting cell , can be heavy on the cpu but since you only do the check on refresh of the board "brute" may be feasible performance wise, since the the matching items limit the paths to check pretty fast.

    first you check the 8 cells around the origin for matching items and from thoose that match the item you check their 7 surrounding cells for aother matching item (of course ignoring the cell you "come" from)

    since you need to check only against a chain length of, 3 thats it.

    worst case performance wise would be 5x5 of the same items since all possible chains would be valid, but highly unlikely

    just checked your screenshot of the game and your playfield is rather small
    so that should be ok.
     
  5. lazypeon

    lazypeon Well-Known Member
    Patreon Bronze

    I think Mr. Ugly has the right idea. I feel like there's probably a more efficient way to do it, but I can't think of it.

    Worst case, you're looking at n*n tiles to check. To find that magical '3-chain', you'd need to check each adjacent tile (so the 8 surrounding tiles) and then the 16(?) tiles around that. At worst, you're looking at 6 * 6 * (24) = 864 if-conditions in the worst case, which I think is doable. I'm sure there's an optimization in here somewhere, because you'd end up revisiting the same tile multiple times.

    You might be able to come up with something more efficient if you fudge the randomization, and use some trick to choose new tiles (when replacing) that will form at least one new pattern.

    Another approach I was thinking of is to keep track of all the existing chains on the board; that is to say, if you have a gun tile, the gun would know all the other guns that are linked as part of the same chain. To accomplish this, on the initial start, you'd run an algorithm to build the links between all the tiles in a chain. As players removed tiles, and new ones are added, you'd simply see if the new tiles could be added to an existing chain or not. Determining if there was a chain could be accomplished by sorting all of the chains you're aware of on the board.

    Not sure on any of these solutions, just kind of thinking out loud.
     
  6. songkranw

    songkranw Well-Known Member

    Here some result.

    Try making a topic at GameDev.net still woking on their idea.

    Checking all the tile seem to be the current solution I use but the result is there're still a rare case where it failed to detect the situation. Still don't know why maybe it failed in my algorithm.

    I still don't know the way of checking tile before put it in the board.
     
  7. mr.Ugly

    mr.Ugly Well-Known Member

    Dec 1, 2009
    1,673
    0
    36
    Berlin, Germany
    #7 mr.Ugly, May 3, 2013
    Last edited: May 3, 2013
    erm i quote myself because one should not contribute on such topics half asleep from bed tz tz

    of course you search for the first valid link on your board and then stop, since you only need one valid chain

    so you would never need to check all cells of the 5x5 grid


    and lazy 864 if conditions? that sounds like hardwired.

    A recursive function that checks against its max 8 neighbors and checks again from the valid cells position the function might find should be sufficient.
     

Share This Page