I have just initialized an array of random values but I would like that in the case where 3 values are aligned, my array is regenerated in such a way that, as of its initialization my array never comprises 3 consecutive similar values.
I am a beginner in C ++, and I don't know what it is the best way to go about it, is it better to create functions that will check if my previous box in my array is similar? or do it directly in my array set up function? Below here is the creation of my table. Many thanks for your help.
void CPlateau::CreatePlateau()
{
m_arrPlateau = new int*[m_iLignes];
for (int ligne = 0; ligne < m_iLignes; ligne++)
{
m_arrPlateau[ligne] = new int[m_iColonnes];
for (int col = 0; col < m_iColonnes; col++)
m_arrPlateau[ligne][col] = 0;
}
}
void CPlateau::SetupPlateau()
{
if (m_arrPlateau == NULL)
CreatePlateau();
for (int ligne = 0; ligne < m_iLignes; ligne++)
for (int col = 0; col < m_iColonnes; col++)
m_arrPlateau[ligne][col] = (rand() % 7);
}