Yet another problem... This one is a while loop, but I know this should work, as less than 10 lines down, there is another while loop along exactly the same principle, and that works...
As you can see, we are generating a random number to be used in the empireCode string type, and then assigning what is stored in there to systemOwn[val]. The maplocation[random,random2,0] array is a number between 100 and 599. Then the obvious while loop. Which looks good... Like the code I spoke of earlier -Code:wjh = rnd2.Next(0,11); systemOwn[maplocation[random,random2,0]] = empireCode[wjh]; exists2 = SystemOwner.Contains(systemOwn[maplocation[random,random2,0]]); while(exists2 == true) { wjh = rnd3.Next(0,11); systemOwn[maplocation[random,random2,0]] = empireCode[wjh]; exists2 = SystemOwner.Contains(systemOwn[maplocation[random,random2,0]]); } SystemOwner.Push(systemOwn[maplocation[random,random2,0]]);
Virtually exactly the same thing, the only difference being the names of the variables I am using. So why doesn't the first one continue through the first one when it encounters an instance already contained inside the stack? Closest I have come to solving this is, it doesn't like a random function inside the brackets on the empireCode variable.Code:maplocation[random,random2,efg] = rnd3.Next(100,599); exists = mapLocCount.Contains(maplocation[random,random2,efg]); while(exists == true) { maplocation[random,random2,efg] = rnd4.Next(100,599); exists = mapLocCount.Contains(maplocation[random,random2,efg]); } mapLocCount.Push(maplocation[random,random2,efg]);
Help!
Btw, no nitpicking my general coding style. workingUglyCode = good; brokenSexyCode = Bad;



LinkBack URL
About LinkBacks


