Support our Sponsors:

Go Back   Touch Arcade > Developer Discussion > Public Game Developers Forum

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2013, 07:12 PM
songkranw's Avatar
songkranw songkranw is offline
Senior Member
iPhone 4, iOS 6.x
 
Join Date: Jun 2009
Location: Thailand : land of smile ^_^
Posts: 141
Default Please help! how can I fix the no more move situations.

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.
Reply With Quote
  #2  
Old 05-02-2013, 07:24 PM
AlienSpace's Avatar
AlienSpace AlienSpace is offline
Developer
iPhone 4, iOS 6.x
 
Join Date: May 2010
Posts: 410
Default

I suggest you go to Gamedev.net and post the question on one of the programming forums there. You will probably get a good answer quickly.

http://www.gamedev.net/page/index.html
Reply With Quote
  #3  
Old 05-02-2013, 10:41 PM
songkranw's Avatar
songkranw songkranw is offline
Senior Member
iPhone 4, iOS 6.x
 
Join Date: Jun 2009
Location: Thailand : land of smile ^_^
Posts: 141
Default

Thank you! going there now.
Reply With Quote
  #4  
Old 05-02-2013, 11:10 PM
mr.Ugly's Avatar
mr.Ugly mr.Ugly is offline
Senior Member
 
Join Date: Dec 2009
Location: Berlin, Germany
Posts: 1,624
Default

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.

Last edited by mr.Ugly; 05-02-2013 at 11:12 PM..
Reply With Quote
  #5  
Old 05-03-2013, 02:39 AM
lazypeon's Avatar
lazypeon lazypeon is offline
Senior Member
iPhone 4, iOS 6.x
 
Join Date: Feb 2009
Location: San Jose, CA
Posts: 543
Default

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.
Reply With Quote
  #6  
Old 05-03-2013, 06:11 AM
songkranw's Avatar
songkranw songkranw is offline
Senior Member
iPhone 4, iOS 6.x
 
Join Date: Jun 2009
Location: Thailand : land of smile ^_^
Posts: 141
Default

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.
Reply With Quote
  #7  
Old 05-03-2013, 08:55 AM
mr.Ugly's Avatar
mr.Ugly mr.Ugly is offline
Senior Member
 
Join Date: Dec 2009
Location: Berlin, Germany
Posts: 1,624
Default

Quote:
Originally Posted by mr.Ugly View Post
worst case performance wise would be 5x5 of the same items since all possible chains would be valid, but highly unlikely
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.

Last edited by mr.Ugly; 05-03-2013 at 10:14 AM..
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 2012, TouchArcade.com, LLC.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Copyright 2008 - 2011, TouchArcade.com. Privacy Policy / DMCA Copyright Agent