Jump to content
  • Advertisement
Sign in to follow this  
AlternateIdea

Randomizing and storing matching tiles

This topic is 3030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm working on a simple 2d grid-based tile matching game. This is something new for me and I'd love to get some advice on how I would go about creating a random set of matchable tiles (e.g. ensuring that a tile gets added to the board twice, so a match can be made).

* I have a set of 50 tiles to choose from
* The game board would be 6x6
* If Tile1 was randomly selected and added to the board, I'd need to ensure that it was also added elsewhere on the board, thus making a match possible.

I thought about creating an array with 18 random entries, and then using those 18 entries to create another random array with 18 entries, thus netting me 36 tiles. Finally I would combine the arrays and shuffle the entries.

This approach sounds like it would work, but I'm curious if there is a more efficient way to go about doing this? Any advice you could offer would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Have you thought about selecting a card a random and then randomly placing it twice?

Or when you select a card to place on the board, place another of the same card right next to it and then randomise the locations by shuffling?

eg. after first placing the cards, but before shuffling you would have 1 1 2 2 3 3, after shuffling 1 3 2 3 1 2

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!