I am working on a small program that simulates the game Memory that we all used to play as a child. Just to refresh everyone, memory was a game where you laid out x amount of cards face down and had to find a match for each card. The player that found the most matches would win the game. My problem is, I don't know how to keep track of how many of each "card" I plan to lay down!!!
Here is what I'm thinking: Initialize a 3x6 array with numbers from 1-9 that will act as the cards for the game. But, how can I keep track of how many times each number 1-9 has been used?? Remember, it can't be more than 2 for each because an even amount of matches is required. Any suggestions/code you provide would be appreciated.
I'm thinking maybe initialize ANOTHER 3x6 array that does nothing but keep track of the numbers of the main array. For example, element 0 of our "counter" array would be set to 'true' everytime it's corresponding number (in this case '1') was set to a card. But once 1 is used twice, element 0 of the counter array would be set to false. When setting up the cards, any elements that have value 'false' would be skipped over because the program would "know" that that particular number and its match are already in the deck of cards. Make sense, or am I just nuts? ;)
Thx in advance!,