Thread: math.random 50% chance?

Results 1 to 3 of 3
  1. #1 math.random 50% chance? 
    Donator


    Join Date
    Jul 2009
    Posts
    1,875
    Thanks given
    119
    Thanks received
    233
    Rep Power
    408
    im trying to make something have a 50% chance of doing something, or doing something else... how would i do this? have never used math.random
    Reply With Quote  
     

  2. #2  
    Renown Programmer
    Method's Avatar
    Join Date
    Feb 2009
    Posts
    1,455
    Thanks given
    0
    Thanks received
    845
    Rep Power
    3019
    Have you tried something like this?

    Code:
    if (Math.random() < 0.5)
      // do this
    else
      // do that
    :-)
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Donator


    Join Date
    Jul 2009
    Posts
    1,875
    Thanks given
    119
    Thanks received
    233
    Rep Power
    408
    Quote Originally Posted by Method View Post
    Have you tried something like this?

    Code:
    if (Math.random() < 0.5)
      // do this
    else
      // do that
    nope, exactly what i was lookin for. ty.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. which has better chance
    By Dream Designs in forum Showcase
    Replies: 2
    Last Post: 02-08-2012, 09:48 PM
  2. Random percent chance
    By Thug in forum Help
    Replies: 5
    Last Post: 04-18-2010, 11:10 PM
  3. Replies: 1
    Last Post: 02-05-2010, 04:08 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •