Page 2 of 2 FirstFirst 12
Results 26 to 47 of 47

Thread: The Big "Write a Portal Finder" competition!

  1. #26
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Added some information about how the testing will go to the OP The function will be tested live i.e. implemented in the script! There is no better way to see how it works than that, right?
    Last edited by Markus; 09-25-2014 at 01:43 PM.
    I made a new script, check it out!.

  2. #27
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    You should incorporate the fact that the portal colors change every log in. For instance, looking at my .gif and NKN's .gif, the portal is blue in mine, but purple in his.

    So within those 25 trials maybe 5 trials per log in?

  3. #28
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    I'll use around five accounts, switch every 4-7 loads as usual. Should take most random factors into account as I can't run it for more than three hours straight.
    I made a new script, check it out!.

  4. #29
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Wow, this thread grew pretty quickly. Good to see my old code has been used as an example I might give this competition a try later this week. I might have an old school trick up my sleeves

    Script source code available here: Github

  5. #30
    Join Date
    Jun 2008
    Location
    United States
    Posts
    818
    Mentioned
    60 Post(s)
    Quoted
    90 Post(s)

    Default

    Same, and same. @Markus, apologies in advance if I end up embarrassing myself.
    [10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts

  6. #31
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    No need to, I'd love you all to participate.
    The currently submitted finders weren't perfect so you still have a good chance of winning!
    I made a new script, check it out!.

  7. #32
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  8. #33
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Fyi: My account got permed so my prize might be delayed in getting to you :/
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  9. #34
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Hello people, (Long time no post )

    I just couldn't resist taking a part of this competition.

    Bear with me, it has been like 1, 5 years since I touched Simba

    Simba Code:
    function FindPortal() :Boolean;
    var
      Le, I, X, Y, W, H, Bmp, Bmp2: Integer;
      TPA: TPointArray;
      TIA, TIA2 :TIntegerArray;
      ATPA :T2DPointArray;
      TBA :TBoxArray;
      PortalPoint :TPoint;
    begin
      Result := False;
      Bmp := bitmapFromClient(mainScreen.getBounds);
      Wait(52);
      Bmp2 := bitmapFromClient(mainScreen.getBounds);
      GetBitmapSize(Bmp, W, H);

      If (W < 100) or (H < 100) then
      begin
        FreeBitmap(Bmp);
        FreeBitmap(Bmp2);
        Exit;
      end;

      for Y := 1 to H - 1 do
        for X := 1 to W - 1 do
          If FastGetPixel(Bmp, X, Y) <> FastGetPixel(Bmp2, X, Y) then
            TPA.Append(Point(X, Y));

      ATPA := TPA.cluster(5);
      TBA := ATPA.getEachBounds;
      Bmp := ContrastBitmap(Bmp, 100);

      Le := Length(TBA);

      If (Le = 0) then
      begin
        FreeBitmap(Bmp);
        FreeBitmap(Bmp2);
        Exit;
      end;

      SetLength(TIA2, Le + 1);

      for I := 0 to Le - 1 do
        If (Distance(Point(0, TBA[I].Y1), Point(0, TBA[I].Y2)) > 40) then
          TBA[I] := IntToBox(0, 0, 0, 0);

      for I := 0 to Le - 1 do
        for Y := TBA[I].Y1 to TBA[I].Y2 do
          for X := TBA[I].X1 to TBA[I].X2 do
            If FastGetPixel(Bmp, X, Y) = clWhite then
              TIA2[I] := TIA2[I] + 1;

      PortalPoint := MiddleTPA(ATPA[TIA2.returnInArray(MaxA(TIA2))]);

      Mouse(PortalPoint, MOUSE_MOVE);
      Result := isMouseOverText(['rtal'], 50, True);

      FreeBitmap(bmp);
      FreeBitmap(bmp2);
    end;


    Edit: Updated code.

    Note: I didn't wan't to use any kind of Minimap symbols to aid on this one, mainly because of the challenge :P

    So how above code works:

    Script gets 2 Bitmaps, calculates difference between them and outputs TPA.
    Divides them into ATPA Using TPA.Cluster.
    Clears all ATPA's which height is more than 40px.
    Grab first bitmap again and add Maximum brightness to it (So pretty much everything is white).
    Calculates white color from inside all ATPA Boundaries.
    Results biggest amount white color Index and applies it to ATPA Index.

    Above code should work very well, angle doesn't matter, all it needs that portal is just a little bit shown in mainscreen.

    Ask if you have any questions about the code


    ~Home
    Last edited by Home; 10-08-2014 at 08:45 PM.

  10. #35
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Home View Post
    Hello people, (Long time no post )

    I just couldn't resist taking a part of this competition.

    Bear with me, it has been like 1, 5 years since I touched Simba

    ~Home
    Looks like you've remembered quite a bit
    @Markus; let me know if/when you want my GP.

  11. #36
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Pretty short, but works perfectly!






    The GIFs make it look slow but it takes about 40-60ms per search.
    Good luck to everyone participating!

    Simba Code:
    program ClarityPortalFinder;
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    const
      DESIRED_TEST_LENGTH = 60; //in seconds
      TIME_DELAY = 100;         //delay between repeated function performance trials, in ms
    //Place these functions in your script so that they are in the correct order, the
    //portal point will result from findPortal; in line 112;
    var
      bmp, dtm, x, y: integer;
      captureBox: TBox;
      pnt, portalPoint: TPoint;
      timer: TTimeMarker;
    {<credit to Bonsai>}
    procedure greyBmp(var bmp: integer);
    var
      b, g: integer;
    begin
      b := copybitmap(bmp);
      g := greyscalebitmap(b);
      freebitmaps([bmp, b]);
      bmp := g;
    end;

    function getMotionBitmap(b: TBox; n: integer = 1; c: integer = 255): integer;
    var
      image1, image2, work1, work2, diffBmp, i, j, w, h, old, new, diffCount: integer;
    begin
      image1 := bitmapfromclient(b);
      sleep(38);
      image2 := bitmapfromclient(b);
      getbitmapsize(image1, w, h);
      diffBmp := createbitmap(w, h);
      work1 := copybitmap(image1);
      work2 := copybitmap(image2);
      greyBmp(work1);
      greyBmp(work2);
      for i := 0 to w - 1 with n do
        for j := 0 to h - 1 with n do
        begin
          old := fastgetpixel(work1, i, j);
          new := fastgetpixel(work2, i, j);
          if (old <> new) then
          begin
            inc(diffCount);
            if (diffCount > 6000) then
              break(2);
            if (c = 0) then
              fastsetpixel(diffBmp, i, j, old)
            else if (c = - 1) then
              fastsetpixel(diffBmp, i, j, new)
            else
              fastsetpixel(diffBmp, i, j, c);
          end;
        end;
      result := diffBmp;
      freebitmaps([image1, image2, work1, work2]);
    end;
    {</credit to Bonsai>}
    function processMotionOutput(b: integer): TPoint;
    var
      oldTarget, w, h, i, dtm: integer;
      pnt: TPoint;
      tpa: TPointArray;
    begin
      oldTarget := GetImageTarget();
      setTargetBitmap(b);
      getbitmapsize(b, w, h);
      findcolors(tpa, 255, 0, 0, w - 1, h - 1);
      setImageTarget(oldTarget);
      mainscreen.filterPointsPlayer(tpa);
      tpa.filterPointsBox(captureBox);
      if length(tpa) >= 15 then
      begin
        result := tpa.getMiddle();
        smartImage.drawPolygon([point(result.x, result.y + 10), point(result.x, result.y + 30)], clBlue);
        smartImage.drawPolygon([point(result.x + 10, result.y), point(result.x + 30, result.y)], clBlue);
        smartImage.drawPolygon([point(result.x - 10, result.y), point(result.x - 30, result.y)], clBlue);
        smartImage.drawPolygon([point(result.x, result.y - 10), point(result.x, result.y - 30)], clBlue);
        smartimage.drawCross(result, 5, clBlue);
        smartimage.drawCircle(result, 25, false, clRed);
      end;
    end;

    function findPortal: TPoint;
    var
      dtm, x, y: Integer;
    begin
      timer.start;
      dtm := DTMFromString('mWAAAAHicY2FgYMhkYWDIAeJUIM4AYlFGBgZuIOYFYnYgLu7az3BlmhrDtCg1BmdnZwY2oB5mJMyIhkEAAIX2By0=');
      if findDTM(dtm, x, y, minimap.getBounds()) then
        begin
          pnt := minimap.pointToMainscreen(point(x, y));
          captureBox := IntToBox(pnt.x - 40, pnt.y - 40, pnt.x + 40, pnt.y + 40);
        end;
      bmp := getMotionBitmap(mainscreen.getBounds(), 2);
      result := processMotionOutput(bmp);
      freebitmap(bmp);
      freeDTM(dtm);
      writeln('Found portal in: ' + tostr(timer.getTime) + 'ms');
    end;

    //Testing code
    begin
      smartEnableDrawing := true;
      setupSRL();
      while getTimeRunning < (DESIRED_TEST_LENGTH * 1000) do
      begin
        findPortal; //Result of this function is TPoint of the portal.
        wait(TIME_DELAY);
        smartImage.clear;
        clearDebug;
      end;
    end.
    Last edited by Clarity; 10-08-2014 at 01:56 AM.

  12. #37
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by Clarity View Post
    Pretty short, but works perfectly!






    The GIFs make it look slow but it takes about 40-60ms per search.
    Good luck to everyone participating!

    Simba Code:
    program ClarityPortalFinder;
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    const
      DESIRED_TEST_LENGTH = 60; //in seconds
      TIME_DELAY = 100;         //delay between repeated function performance trials, in ms
    //Place these functions in your script so that they are in the correct order, the
    //portal point will result from findPortal; in line 112;
    var
      bmp, dtm, x, y: integer;
      captureBox: TBox;
      pnt, portalPoint: TPoint;
      timer: TTimeMarker;
    {<credit to Bonsai>}
    procedure greyBmp(var bmp: integer);
    var
      b, g: integer;
    begin
      b := copybitmap(bmp);
      g := greyscalebitmap(b);
      freebitmaps([bmp, b]);
      bmp := g;
    end;

    function getMotionBitmap(b: TBox; n: integer = 1; c: integer = 255): integer;
    var
      image1, image2, work1, work2, diffBmp, i, j, w, h, old, new, diffCount: integer;
    begin
      image1 := bitmapfromclient(b);
      sleep(38);
      image2 := bitmapfromclient(b);
      getbitmapsize(image1, w, h);
      diffBmp := createbitmap(w, h);
      work1 := copybitmap(image1);
      work2 := copybitmap(image2);
      greyBmp(work1);
      greyBmp(work2);
      for i := 0 to w - 1 with n do
        for j := 0 to h - 1 with n do
        begin
          old := fastgetpixel(work1, i, j);
          new := fastgetpixel(work2, i, j);
          if (old <> new) then
          begin
            inc(diffCount);
            if (diffCount > 6000) then
              break(2);
            if (c = 0) then
              fastsetpixel(diffBmp, i, j, old)
            else if (c = - 1) then
              fastsetpixel(diffBmp, i, j, new)
            else
              fastsetpixel(diffBmp, i, j, c);
          end;
        end;
      result := diffBmp;
      freebitmaps([image1, image2, work1, work2]);
    end;
    {</credit to Bonsai>}
    function processMotionOutput(b: integer): TPoint;
    var
      oldTarget, w, h, i, dtm: integer;
      pnt: TPoint;
      tpa: TPointArray;
    begin
      oldTarget := GetImageTarget();
      setTargetBitmap(b);
      getbitmapsize(b, w, h);
      findcolors(tpa, 255, 0, 0, w - 1, h - 1);
      setImageTarget(oldTarget);
      mainscreen.filterPointsPlayer(tpa);
      tpa.filterPointsBox(captureBox);
      if length(tpa) >= 15 then
      begin
        result := tpa.getMiddle();
        smartImage.drawPolygon([point(result.x, result.y + 10), point(result.x, result.y + 30)], clBlue);
        smartImage.drawPolygon([point(result.x + 10, result.y), point(result.x + 30, result.y)], clBlue);
        smartImage.drawPolygon([point(result.x - 10, result.y), point(result.x - 30, result.y)], clBlue);
        smartImage.drawPolygon([point(result.x, result.y - 10), point(result.x, result.y - 30)], clBlue);
        smartimage.drawCross(result, 5, clBlue);
        smartimage.drawCircle(result, 25, false, clRed);
      end;
    end;

    function findPortal: TPoint;
    var
      dtm, x, y: Integer;
    begin
      timer.start;
      dtm := DTMFromString('mWAAAAHicY2FgYMhkYWDIAeJUIM4AYlFGBgZuIOYFYnYgLu7az3BlmhrDtCg1BmdnZwY2oB5mJMyIhkEAAIX2By0=');
      if findDTM(dtm, x, y, minimap.getBounds()) then
        begin
          pnt := minimap.pointToMainscreen(point(x, y));
          captureBox := IntToBox(pnt.x - 40, pnt.y - 40, pnt.x + 40, pnt.y + 40);
        end;
      bmp := getMotionBitmap(mainscreen.getBounds(), 2);
      result := processMotionOutput(bmp);
      freebitmap(bmp);
      freeDTM(dtm);
      writeln('Found portal in: ' + tostr(timer.getTime) + 'ms');
    end;

    //Testing code
    begin
      smartEnableDrawing := true;
      setupSRL();
      while getTimeRunning < (DESIRED_TEST_LENGTH * 1000) do
      begin
        findPortal; //Result of this function is TPoint of the portal.
        wait(TIME_DELAY);
        smartImage.clear;
        clearDebug;
      end;
    end.
    barnicals, I should've done motion detection in my little box too.

    rip

  13. #38
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Woops! Guess I disappeared again.
    Will try them asap! Got exams now *hates differential equations*
    I made a new script, check it out!.

  14. #39
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    @Markus Any update on this?



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  15. #40
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    I'll look into it later this week, thanks for all the submissions!
    I made a new script, check it out!.

  16. #41
    Join Date
    Aug 2013
    Posts
    159
    Mentioned
    4 Post(s)
    Quoted
    90 Post(s)

    Default

    I might actually try this if I knew didn't know there was already over 3 entries from skilled people here. Seeing things like this challenges me to get better at scripting and try to achieve what I probably couldn't now.

  17. #42
    Join Date
    Jan 2012
    Location
    127.0.0.1
    Posts
    702
    Mentioned
    11 Post(s)
    Quoted
    76 Post(s)

    Default

    Quote Originally Posted by Markus View Post
    [SIZE=7][B][CENTER]The Big "Write a Portal Finder" competition!

    No but still, how can I win?
    Besides by scoring high on the scoring criteria, I love transformations! If you use a Gabor, LaPlace, Fourier or maybe even wavelets, you will get a LOT of bonus points and I'll ignore all other rules.

    Good luck!
    Haha can I just port my code for a CAS that solves most transforms to Simba? (All other rules ignored so it doesnt have to even be a portal finder

  18. #43
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

  19. #44
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Will take a good look at this in the first week of February, dw!
    I made a new script, check it out!.

  20. #45
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    @J J; is the winner!
    His portal finder is very accurate and works in both RS3 and OSRS without modifications!

    Sorry it took three years to go the grading but never late than never!

    Edit: sorry! It's a tie with @Clarity! His finder is just as good

    Both finders use very similar approaches: use the symbol location from the minimap and convert it to MS coordinates. Very smart.
    Last edited by Markus; 01-15-2017 at 09:54 AM.
    I made a new script, check it out!.

  21. #46
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Happy to share the win with @Clarity, thank you for providing the results @Markus

    Script source code available here: Github

  22. #47
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 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
  •