Results 1 to 9 of 9

Thread: Quick Question...

  1. #1
    Join Date
    Aug 2007
    Location
    Where do you live?
    Posts
    934
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Quick Question...

    How can I get SCAR to choose a random number but skipping 1 (or more) numbers in the middle?

    Ex: Random(12) --> But SKIP 7

    or somethin like that...

    I'm tempted to script my own BlackJack game with SCAR that's why I'm asking this... like when dealing out cards, if I have a 7 and a 10 and the dealer has a 2, 8, 6, and 3 I would like to eliminate those six cards from the deck (So the statistics are accurate)

  2. #2
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Would this work?

    SCAR Code:
    case Random(2...14,16...24) of
    ...stuff

    That way it would skip 15?

    eh, I dont know Im kind of confusing myself thinking about it lol.

  3. #3
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function RandomSkip(fromwhat, towhat : integer; skipnums : TIntegerArray) : integer;
    var
      ii : integer;
    begin
      if getarraylength(skipnums) = 0 then exit;
      repeat
        result := randomrange(fromwhat, towhat);
        for ii := 0 to high(skipnums) do
        begin
          if result <> skipnums[ii] then
          exit;
        end;
      until(result <> skipnums[ii]);
    end;

    Maybe a bit more then needed but I'm really tired .
    Use it like
    SCAR Code:
    writeln(inttostr(RandomSkip(1, 5, [3])));

  4. #4
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Looks like that would work. Standards tho
    SCAR Code:
    function RandomSkip(fromwhat, towhat : integer; skipnums : TIntegerArray) : integer;
    var
      ii : integer;
    begin
      if getarraylength(skipnums) = 0 then
        Exit;
      repeat
        result := randomrange(fromwhat, towhat);
        for ii := 0 to high(skipnums) do
          begin
            if result <> skipnums[ii] then
              Exit;
          end;
      until(result <> skipnums[ii]);
    end;

    ~Camo
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  5. #5
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    375
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    number := random(x);
    if (number = 7) then inc(number);
    :P

  6. #6
    Join Date
    Sep 2006
    Location
    include srl/srl.scar ( aussie)
    Posts
    2,875
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function RandomBut(Random,But: Integer): Integer;
    var
      I: Integer;
    begin
      for I:= 0 to High(Random) do
      begin
        Result:= Random(Random);
        if not Result = But then
        begin
          break;
        end else
        begin
          if I= High(Random) then
          begin
            Inc(Result);
            Break;
          end;
          Continue;
        end;
      end;
    end;

    Try that , written in post so may not work.

    Edit:

    Da 0wner was right your standars are more off


    SCAR Code:
    function RandomSkip(fromwhat, towhat : integer; skipnums : TIntegerArray) : integer;
    var
      ii : integer;
    begin
      if getarraylength(skipnums) = 0 then
        Exit;
      repeat
        result := randomrange(fromwhat, towhat);
        for ii := 0 to high(skipnums) do
          begin
            if result <> skipnums[ii] then
              Exit;
          end;
      until(result <> skipnums[ii]);
    end;

    SCAR Code:
    for ii := 0 to high(skipnums) do
      begin

    I know your ment to do 2 spaces areter a for do but if its a begin forget the spaces. same with an if then.

  7. #7
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Ah ok. I didn't know bout that. Thanks for clarifying
    Inc(FailTimes); Lol

    ~Camo
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  8. #8
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default


    inc(Leetness);

    This would work my previous one would not.

    SCAR Code:
    function RandomEx(Range1, Range2 : integer; Exception : integer) : integer;
    var
      i : integer;
    begin
      repeat
        result := RandomRange(Range1, Range2);
        if result <> Exception then exit;
      until(false);
    end;

    Writeln(IntToStr(RandomEx(1, 11, 7)));

  9. #9
    Join Date
    Aug 2007
    Location
    Where do you live?
    Posts
    934
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks guys

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Just a quick question? Did I say quick?
    By SeanJohn in forum OSR Help
    Replies: 3
    Last Post: 01-28-2009, 12:03 AM
  2. Quick question
    By GinFoxface in forum OSR Help
    Replies: 2
    Last Post: 04-07-2007, 04:25 AM
  3. Quick Question
    By mage of begu in forum OSR Help
    Replies: 10
    Last Post: 01-12-2007, 10:48 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
  •