You might find my Complex Randomisation demo useful
For example you could have a list of runs for each colour, such as
runs1 = [3,3,3,2,2,2,2,1,1,1]
shuffle(runs1)
rows1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
shuffle(rows1)
runs2 = [3,3,3,2,2,2,2,1,1,1]
shuffe(runs2)
rows2 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
shuffle(rows2)
startRow = [0,20]
shuffle(startRow)
useRows = []
for Idx in range(10):
for Jdx in range(runs1.pop()):
useRows.append(rows1.pop()+startRow[0])
for Jdx in range(runs2.pop()):
useRows.append(rows2.pop()+startRow[1])
Then set your main loop to use useRows sequentially.