If you're making a bejeweled type game, you're going to need a function to check for sequences during the course of game play. You could use this same function during initialization to check for sequences after randomly determining the starting values. If any are found, change those spots to new characters. Repeat until there are no duplicates side by side.