Assign specific value to random

Discussion in 'Public Game Developers Forum' started by bonzer1, Aug 6, 2009.

  1. bonzer1

    bonzer1 New Member

    Aug 6, 2009
    1
    0
    0
    Hello i try to use arc4random function to estract sono text from a file, but the file have 100 lines and i'd like that the random function estract only a specific random line such as 6 - 12 - 18 - 24 - 30 . . . multiple of 6.
    it's possible?

    This is my actual code
    Code:
    int numLines = [rowFile count];
    	
    	
    	
    	int row = arc4random() % numLines;
    
     
  2. iamflimflam1

    iamflimflam1 Active Member

    Mar 14, 2009
    26
    0
    0
    How about this?

    Code:
    int numLines = [rowFile count];
    int row = 6*(arc4random() % (numLines/6));
    
     
  3. 99c_gamer

    99c_gamer Well-Known Member

    Mar 23, 2009
    659
    0
    0
    you could use something like

    row = random()%(numLines/6) * 6;
     

Share This Page