これが私のコードです:
-(void)randommoves
{
NSArray *possiblemoves =[NSArray arrayWithObjects:@"R ",@"R' ",@"L ",@"L' ",@"B ",@"B' ",@"F ",@"F' ",@"U ",@"U' ",@"D ",@"D' ", nil];
NSMutableString *finalmoves = [[NSMutableString alloc] init];
finalmoves = [NSMutableString stringWithCapacity:0];
[finalmoves retain];
int i = 0;
for (i=0; i<20; i++) {
int r = rand() % 13;
NSString *string = [possiblemoves objectAtIndex:r];
[finalmoves appendString:string];
}
NSLog(@"%@",finalmoves);
[finalmoves release];
}
そして、実行するたびに、まったく同じ文字列「D'B B'D L'D' F'L' B'U' DD D'L' URBFD'B'」が表示されます。
私がやりたいのは、実行するたびに新しいムーブセットをくれることです
これを少なくとも30回実行して、それがまぐれではないこと、そして実際に同じ文字列を返していることを確認しました。確かにそうです。