Set up a weighted array. Let's say the last value was 2. Create an array like this:
array = [0,0,0,0,1,1,1,1,2,3,3,3,3];
Then select the number in the array.
newValue = array[arc4random() % 13];
Now switch to using math instead of an array.
newValue = ( ( ( arc4random() % 13 ) / 4 ) + 1 + oldValue ) % 4;
For possibilities P and weight 0<W<=1 use:
newValue = ( ( ( arc4random() % (P/WP(1-W)) ) * W ) + 1 + oldValue ) % P;
For P = 4 and W = 1/4 (P / WP (1-W)) = 13. This suggests that the latter value will be 1/4 more likely than others.
If you completely eliminate the most recent answer, it will be as noticeable as the most recent answer, which appears too often. I don’t know what weight will be right for you, but 1/4 is a good starting point.
source share