Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Randomization
Author Message
born130

Posted: Thu Jun 26, 2003 9:28 pm   Post subject: Randomization

From my earlier topic

I just wanted to know how i could randomize each of left, right, up, down
so that i would not have to make screen after screen.

Thanks

Dan

Posted: Thu Jun 26, 2003 10:25 pm   Post subject: (No subject)

not shure what you whont to randomize, but you could make a fuction that picks a random number from one to max # of posaibliteys and then uses ifs or a case thingy for each number to do somting.

random code:

randint ( var i : int, low, high : int )

also need to use randomize at beging of progame so you dont get same random numbers.

Ex of random code:

 code: randomize var roll : int var i:int loop     randint ( i, 1, 6 )     put "Rolled ", i end loop
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
born130

Posted: Thu Jun 26, 2003 10:28 pm   Post subject: (No subject)

basically i just want it to randomize

three moves out of four

i.e. out of up left right down it would choose 3 of them in a random order
Tony

Posted: Thu Jun 26, 2003 11:56 pm   Post subject: (No subject)

so run a loop, and mark those picked, then next time randomly pick from those left (or keep on picking untill you end up with one that is not marked yet)
Tony's programming blog. DWITE - a programming contest.
Andy

Posted: Fri Jun 27, 2003 9:20 am   Post subject: (No subject)

basicly what u do is randomly choose one key that u don't want and just keep the rest, here's the code

 code: var keys:array 1..4 of int:=init(200,203,205,208) var unwantedkey:=keys(Rand.Int(1,4)) var count:=0 var finalkeys:array 1..3 of int for i:1..4 count+=1 if keys(count)not=unwantedkey then finalkeys(count):=keys else count+=1 end if end for
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: