Brute force method - should be fine for small grids like 5x5.
Use the advanced random behavior to create a permutation table, 0-5, corresponding to your animation frame.
Fill the first row with the values from the permutation table.
Check if any of the colors in that row match the one above it. If there are, repeat with a new permutation table.
Repeat for following rows.