View Poll Results: Do you think it's good idea?

Voters
14. This poll is closed
  • Yes

    12 85.71%
  • No

    2 14.29%
Results 1 to 13 of 13

Thread: [Request] FindNormalRandoms2

  1. #1
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default [Request] FindNormalRandoms2

    Ok ,so I found big problem ,when I wanted to add 'walk-back from failed random' to my script. FindNormalrandoms doesn't provide all needed information. It outputs TRUE ,if random was solved ,and FALSE ,when random failed either wasn't detected. So we don't know exactly where player is ,when something crash in script - it was failed random or our failed code?

    And if we have in script something like:
    Simba Code:
    if not loggedin then LoginPlayer;
    //or
    AddOnTerminate('CrashSMART');
    if not loggedin then terminatescript;
    we don't know what to expect when we log in again - player might be: in script location , inside random or teleported somewhere for failed random. And it makes things overcomplicated. So I suggest

    Simba Code:
    function FindNormalRandoms2 : integer // or byte
    // output:
    // -1  - failed random
    // 0  - random not detected
    // 1  - solved random

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

    Default

    The main problem with this sort of implementation is that in many cases 'failed random' and 'random not detected' are one in the same.

  3. #3
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    The main problem with this sort of implementation is that in many cases 'failed random' and 'random not detected' are one in the same.
    What do you mean? Randoms are detected or not ,and if detected then solver returns true or false.

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

    Default

    So I suggest

    Simba Code:
    function FindNormalRandoms2 : integer // or byte
    // output:
    // -1  - failed random
    // 0  - random not detected
    // 1  - solved random
    0 and -1 could easily be mistaken for each other by the script, as if a random is present yet not detected, it is then 'failed', and there for the same thing.

  5. #5
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    0 and -1 could easily be mistaken for each other by the script
    I really don't understand this. I guess you maybe talk about a way ,how solver works:
    Simba Code:
    if (SRL_Randoms[rand].solve <> nil) and (SRL_Randoms[rand].solve())

    ,but I don't want to replace current FindNornalRandoms ,but add second expanded. Well ,maybe I should name it FindNormalRandomsEx.

    There is not big deal to add it:

    Simba Code:
    var
    SRL_FailedRandomFlag : boolean; // global flag
    function FindNormalRandomsEx : byte;
    begin
       SRL_FailedRandomFlag := FALSE; // reset flag
       if FindNormalRandoms then
           Result := 1
        else  begin
            if SRL_FailedRandomFlag then Result := -1
            else Result := 0;
        end;
    end;

    then inside function _SolveRandom:
    Simba Code:
    if (SRL_Randoms[rand].solve <> nil) and (SRL_Randoms[rand].solve()) then
          begin
            addToSRLLog('***** Solved Random: '+SRL_Randoms[rand].name+' *****');
            players[currentPlayer].rand := '';
            inc(SRL_Randoms[rand].solved);
            solved := true;
          end else        
             SRL_FailedRandomFlag := TRUE;

  6. #6
    Join Date
    Jan 2012
    Posts
    273
    Mentioned
    7 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    0 and -1 could easily be mistaken for each other by the script, as if a random is present yet not detected, it is then 'failed', and there for the same thing.
    currently -1 and 0 option is being confused because they both return false, so that's a moot point

    edit: i would prefer to have RANDOM_SOLVED, RANDOM_FAILED and RANDOM_NOT_FOUND defined of course....
    Last edited by zmon; 05-21-2012 at 12:40 AM.
    Perfect script? There is no such thing as "perfect", only "better than you expect".

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

    Default

    I think I misunderstood what you posted..

    If this is mainly meant to be a sort of debug, then I would much prefer just adding an attribute to the players array.

    Something like:
    Simba Code:
    //psuedo code..
    if detectRandom then
    begin
      players[currentPlayer].inRandom := True;
      if solveRandom then
        players[currentPlayer].inRandom := False;
    ...

  8. #8
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    I won't persist on my implementation ,there is few more ways. But how would you distinguish in your variant situation when random failed and player was teleported way? Statement:
    (not FindNormalRandoms)and(not(players[currentPlayer].inRandom))
    might mean:
    no randoms detected
    either
    random failed and player was teleported away

  9. #9
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Aren't you now both describing the same thing, or better yet, you both are identifying the same problem that occur, given each of your suggestions towards each other? If not, sorry, I'm just confused. :x

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

    Default

    Quote Originally Posted by beginner5 View Post
    I won't persist on my implementation ,there is few more ways. But how would you distinguish in your variant situation when random failed and player was teleported way? Statement:
    (not FindNormalRandoms)and(not(players[currentPlayer].inRandom))
    might mean:
    no randoms detected
    either
    random failed and player was teleported away
    You can always track most things yourself already with...
    Simba Code:
    srl_OnFindRandom // A global pointer in SRL.
    And now that I check, there is already..
    Simba Code:
    Rand: string;                   // * Current Random
    In the TUser record.

    Honestly, It's all quite possible already. I'm not trying to shoot down your ideas by any means, but rather trying to avoid 'bloat' in the include.

  11. #11
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Well , you are right ,it's possible now.

    Simba Code:
    var
    InRandom : boolean;

    function OnRandomDetect : Boolean;
    begin
      InRandom := TRUE;
    end;

    SRL_Procs[SRL_OnFindRandom] := @OnRandomDetected ;

    function FindNormalRandomsEx : byte;
    begin
       InRandomFlag := FALSE;
       if FindNormalRandoms then
           Result := 1
        else  begin
            if InRandomFlag then
               Result := -1
            else Result := 0;
        end;
    end;

    E: I like TUser.inRandom idea

    E2 : I didn't find .rand resets in other cases then random is solved. So when random fails and teleports player out ,it will still show ,that player is in random. And on the next FindNormalRandoms call ,which doesn't detect anything it will still shows ,that player is in random ,didn't it ? Maybe add reset of .rand at beginning of _SolveRandom? Propably no one expected ,that script will be running after failed random
    Last edited by bg5; 05-21-2012 at 03:23 AM.

  12. #12
    Join Date
    Jan 2012
    Posts
    273
    Mentioned
    7 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Honestly, It's all quite possible already.
    thanks for the thorough answer, i didn't check enough of code yet to know about all these things, very helpful
    Perfect script? There is no such thing as "perfect", only "better than you expect".

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

    Default

    Quote Originally Posted by beginner5 View Post
    E2 : I didn't find .rand resets in other cases then random is solved. So when random fails and teleports player out ,it will still show ,that player is in random. And on the next FindNormalRandoms call ,which doesn't detect anything it will still shows ,that player is in random ,didn't it ? Maybe add reset of .rand at beginning of _SolveRandom?
    I'm not positive of which randoms will telport you, but those solvers should reset .rand accordingly, otherwise they should to be edited to do so.

    Quote Originally Posted by zmon View Post
    thanks for the thorough answer, i didn't check enough of code yet to know about all these things, very helpful
    SRL is full of possibilities and features not many are aware of.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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