My apologies - what  I meant to type was that I AM doing this:

int tmp = (arc4random()%10)+1;

while (tmp == activeTarget) {

  tmp = (arc4random()%10)+1;

}

activeTarget = tmp;


This is for a game, so it's not very critical or anything. Someone told me
that I might want to avoid a while loop at all by doing something like this:


int result = (arc4random()%9) + 1;

if (result >= activeTarget) ++result;

activeTarget = result;


That seems a little odd to me to do things that way - but I'm not really
sure.



On Tue, Apr 14, 2009 at 4:08 PM, Andrew Farmer <andf...@gmail.com> wrote:

> On 14 Apr 09, at 09:24, Eric E. Dolecki wrote:
>
>> to get back to my original question I'm not just doing this:
>>
> <snip>
>
> Then what are you doing? It'd really help to know what you're trying to
> accomplish here.
>
>


-- 
http://ericd.net
Interactive design and development
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to