I have a list of two Vector3 locations (NorthPos and SouthPos). These locations repeat several times on the list. For instance, if the list has 10 elements, half of the elements will be NorthPos and the other half will be SouthPos. I am able to shuffle the elements using the Fisher–Yates shuffle. However, I want to prevent the locations from repeating more than 3 times in a row (e.g. SouthPos, NorthPos, NorthPos, NorthPos, NorthPos, SouthPos, etc.). What’s the best way to do this in C#?
//add items to list
for (int i = 0; i < series1int / 2; ++i) {
StartSeqAcquisition.Add (NorthPos);
}
for (int i = 0; i < series1int / 2; ++i) {
StartSeqAcquisition.Add (SouthPos);
}
//shuffle items for (int t = 0; t < StartSeqAcquisition.Count; t++ )
{
Vector3 tmp = StartSeqAcquisition[t];
int randomIndex = Random.Range(t, StartSeqAcquisition.Count);
StartSeqAcquisition[t] = StartSeqAcquisition[randomIndex];
StartSeqAcquisition[randomIndex] = tmp;
}