C++ Randomize Different Variables Using a Constructor : <p><pre></p>

<p>Robot::Robot()</p>

<code>fitness = 5;
totalBattery = 5;

int randNum;

int i = 0;
bool valid = true;

srand(time(NULL));

//get robot's position on board and check to see if it is not starting on the wall
while (valid)
{
    position = (rand()+i++) % 196;

    if (position &gt;= 0 &amp;&amp; position &lt;= 14)
    { }
    else if ((position % 14) == 0 || (position % 14) == 13)
    { }
    else if (position &gt;= 183 &amp;&amp; position &lt;= 195)
    { }
    else 
    {
        valid = false;
        cout &lt;&lt; endl &lt;&lt; "MY POSITION IS : " &lt;&lt; position &lt;&lt; endl &lt;&lt; endl;    
    }
}

//randomize Robot Genetics
for (int j = 0; j &lt; genes; j++)
{
    for (int k = 0; k &lt; chromosomes; k++)
    {
        //first 4; set N S E W(what the robot looks for in that direction)
        //0 = empty; 1 = battery; 2 = don't care; 3 = wall
        if (k &lt; 4)
        {
          randNum = ((rand()+i++) % 4);
            switch(randNum)
            {
                //Empty Space
                case 0: 
                    DNA[j][k] = " * ";
                    break;

                //Battery
                case 1:
                    DNA[j][k] = " B ";
                    break;

                //Don't Care
                case 2:
                    DNA[j][k] = " D ";
                    break;

                //Wall
                case 3:
                    DNA[j][k] = " W ";
                    break;

                default:
                    cout &lt;&lt; "YOUR CODE SCREWED UP IF YOU ARE IN HERE!! " &lt;&lt; endl;
            }
        }
        //direction facing; N S E W
        else if (k &lt; 5)
        {
            randNum = ((rand()+i++) % 4);
            switch(randNum)
            {
                case 0: 
                    DNA[j][k] = "N";
                    break;

                case 1:
                    DNA[j][k] = "S";
                    break;

                case 2:
                    DNA[j][k] = "E";
                    break;

                case 3:
                    DNA[j][k] = "W";
                    break;

                default:
                    cout &lt;&lt; "YOUR CODE SCREWED UP IF YOU ARE IN HERE!! " &lt;&lt; endl;
                    break;

            }
        }
        //step counter in that direction
        else if (k &lt; 6)
        {
            DNA[j][k] = "0";
        }
        //Rotate Right(R); Rotate Left(L); Move in facing Direction(M); Do Nothing (X)
        else
        {
            randNum = ((rand()+i++) % 4);
            switch(randNum)
            {
                case 0: 
                    DNA[j][k] = "X";
                    break;

                case 1:
                    DNA[j][k] = "L";
                    break;

                case 2:
                    DNA[j][k] = "R";
                    break;

                case 3:
                    DNA[j][k] = "M";
                    break;

                default:
                    cout &lt;&lt; "YOUR CODE SCREWED UP IF YOU ARE IN HERE!! " &lt;&lt; endl;
                    break;

            }
        }
    }   
}
</code></pre>

<p>}
</p>

<p>I am trying to construct objects of a class, and I need 200 of them. I am using a vector and iterating through a while loop and each time i construct a new instance of the class, the objects come out with the exact same data. How are you supposed to properly use the randomizer function to get different data into variables while constructing objects of a class? I tried doing research, but it just got me to this point, and I'm unsure why this isn't working. Thank You in advanced.</p>
