Algorithm to increase odds of matching when randomly selecting

Posted by Bryan on Programmers See other posts from Programmers or by Bryan
Published on 2013-05-30T09:45:33Z Indexed on 2013/06/29 16:29 UTC
Read the original article Hit count: 233

I am building a mobile game loosely based on dual n-back http://brainworkshop.sourceforge.net/tutorial.html

Now with the game I have 9 squares (numbered 1 through 9) and 9 letters (A through K) In the current code, I randomly select a square (e.g. 3) and a letter (e.g. C), then repeat the random selection for the next turn. For 1-back, I test whether either, neither or both match the previous turn.

The problem with my current code is I get very few matches - I can go through many turns without having either match.

How can I increase the match frequency, or alternatively decrease the randomness so a match is more likely?

I am not looking for specific code (but pseudo-code would be fine) - just more an approach to increase match frequency.

© Programmers or respective owner

Related posts about algorithms

Related posts about array