Results 1 to 16 of 16

Thread: Randomizing Integers

  1. #1
    Join Date
    Sep 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Randomizing Integers

    I wrote a script that I want to say yes or no randomly.
    I thought that this would work but apparently i have some problem with the randomizing part because the answer is always "no".


    SCAR Code:
    //Written by Daw_guy
    //used A Beginner Tutorials by bebe and another by whocares357

    program YesorNo;

    var
    flip:integer;

    const
    yes='yes';
    no='no';

    procedure saytheansweris;
    begin
    writeln('the answer is...');
    end;

    procedure sayyes;
    begin
    writeln(yes);
    end;

    procedure sayno;
    begin
    writeln(no);
    end;

    procedure rnumber;
    begin
    flip:= (0+random(1));
    end;



    begin
    rnumber;
    saytheansweris;
    wait(1000)
      if flip=1
         then
           begin
             sayyes;
         end else
              sayno;
    end.

  2. #2
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Random(1) will always return 0. If you want either 0 or 1, then do Random(2). There's also a function called RBool, which randomly returns either true or false. You could use that instead

  3. #3
    Join Date
    Sep 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you for the help i got it to work.
    results so far were yes yes no yes yes no yes no

  4. #4
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    or make it simpler......

    SCAR Code:
    var
       s: TStringArray;
    begin
     S := ['no', 'yes'];
     Writeln(S[Random(Length(s))]);
    end.
    Co Founder of https://www.tagcandy.com

  5. #5
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    *SHOWOFF ALERT! SHOWOFF ALERT!*

    GG SKy, here's a pic for you !!


    [OnTopic]
    daw_guy, you could shorten the script in many ways. For a beginner, I wouldn't suggest SKy Scripter's method. But instead of making the sayyes and sayno procedures, you could replace that with "Writeln('Yes')" (and no, of course) in the mainloop.
    [/OnTopic]

    -Knives

  6. #6
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    Random(1) will always return 0. If you want either 0 or 1, then do Random(2). There's also a function called RBool, which randomly returns either true or false. You could use that instead
    How did you know about that?
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  7. #7
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Santa_Clause View Post
    How did you know about that?
    Umm... I look through the function list when I'm bored...
    I'm such a loser xD

  8. #8
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    You must be my secret brother, bullzeye! I have read the SCAR manual around 3 times, and the whole SRL include 5 times... I do that when I need an excuse to do ANYTHING but what I was supposed to.

    Look at now for example. I have a lot of homework, and I'm going to bed in 20 minutes. But instead, I'm sitting here and posting this.

    *Runs away*

    -Knives

  9. #9
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    im not a show off
    Co Founder of https://www.tagcandy.com

  10. #10
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just do

    SCAR Code:
    Case random(2) of[SCAR]
    1: 'Yes'
    2: 'No'
    end;[/SCAR]

  11. #11
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Umm... I look through the function list when I'm bored...
    I'm such a loser xD
    Wanna tell where is the function list? Like is there a .html or anything?

    "..." gives it too, but no explanations..

  12. #12
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Wanna tell where is the function list? Like is there a .html or anything?

    "..." gives it too, but no explanations..
    If your being serious, hit f1 in scar.

  13. #13
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Lol Myles, scar manual doesn't have all the functions... try to find High for example in SCAR manual.

  14. #14
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    If there is one then I would like to see it as well, because there's many things I want to know how to use.

  15. #15
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Lol Myles, scar manual doesn't have all the functions... try to find High for example in SCAR manual.
    That's why I usually just look through the ctrl + space function + procedure list
    Most are self-explanitory. If I don't know what one does... I lock myself in my room until I figure it out.

  16. #16
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    I lock myself in my room until I figure it out.
    Obsessed...














Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Randomizing Bank Paths
    By ron1337 in forum News and General
    Replies: 6
    Last Post: 11-02-2008, 12:41 AM
  2. Integers
    By Jackrawl in forum OSR Help
    Replies: 16
    Last Post: 12-23-2007, 03:55 PM
  3. Randomizing typesend help!
    By jvwarrior in forum OSR Help
    Replies: 1
    Last Post: 10-28-2007, 11:48 PM
  4. integers!
    By Cruel100 in forum OSR Help
    Replies: 7
    Last Post: 10-27-2007, 04:28 PM
  5. the need for randomizing minimap/camera movements?
    By lvlrdka22 in forum News and General
    Replies: 0
    Last Post: 01-22-2007, 01:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •