Results 1 to 4 of 4

Thread: Tbox Color Array Comparing

  1. #1
    Join Date
    Jul 2008
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Tbox Color Array Comparing

    I'm trying to come up with a good way of finding noted forms of items in the inventory for my lazy merchant bot.

    I developed these functions to do that, Just thought I would share. Any improvements would be awesome.

    Use:
    Code:
    writeln(IntToStr(compareColorArrays(GetColorsFromTBox(InvBox(1)), GetColorsFromTBox(InvBox(2)))));
    Snippet:
    Code:
    function GetColorsFromTBox(loc : TBox): Array of Integer;
    var
      x, y, currentCol, emptySlot, color : Integer;
      found : boolean;
      colors : Array[1..100] of Integer;
    begin
      for x := loc.X1 to loc.X2 do
        begin
          for y := loc.Y1 to loc.Y2 do
            begin
              found := false;
              color := GetColor(x, y);
              for currentCol := 1 to 100 do
                begin
                  if colors[currentCol] = color then
                    begin
                      found := true;
                      Break;
                    end;
                  if colors[currentCol] = 0 then
                    begin
                      emptySlot := currentCol;
                      writeln('Filled up slot' + IntToStr(emptySlot) + ' with: ' + IntToStr(color));
                      Break;
                    end;
                end;
              if not(found) then colors[emptySlot] := color;
            end;
        end;
      Result := colors;
    end;
    
    function compareColorArrays(origColors, searchColors : Array of Integer): Integer;
    var
      i, i2, colorsFound : Integer;
    begin
      for i := Low(origColors) to High(origColors) do
        begin
          for i2 := Low(searchColors) to High(searchColors) do
            begin
              if origColors[i] = searchColors[i2] then
                begin
                  colorsFound := colorsFound + 1;
                  Break;
                end;
            end;
        end;
      Result := colorsFound;
    end;

  2. #2
    Join Date
    Feb 2009
    Location
    inside Hello World! Application
    Posts
    232
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Stuart View Post
    I'm trying to come up with a good way of finding noted forms of items in the inventory for my lazy merchant bot.

    I developed these functions to do that, Just thought I would share. Any improvements would be awesome.

    Use:
    Code:
    writeln(IntToStr(compareColorArrays(GetColorsFromTBox(InvBox(1)), GetColorsFromTBox(InvBox(2)))));
    Snippet:
    Code:
    function GetColorsFromTBox(loc : TBox): Array of Integer;
    var
      x, y, currentCol, emptySlot, color : Integer;
      found : boolean;
      colors : Array[1..100] of Integer;
    begin
      for x := loc.X1 to loc.X2 do
        begin
          for y := loc.Y1 to loc.Y2 do
            begin
              found := false;
              color := GetColor(x, y);
              for currentCol := 1 to 100 do
                begin
                  if colors[currentCol] = color then
                    begin
                      found := true;
                      Break;
                    end;
                  if colors[currentCol] = 0 then
                    begin
                      emptySlot := currentCol;
                      writeln('Filled up slot' + IntToStr(emptySlot) + ' with: ' + IntToStr(color));
                      Break;
                    end;
                end;
              if not(found) then colors[emptySlot] := color;
            end;
        end;
      Result := colors;
    end;
    
    function compareColorArrays(origColors, searchColors : Array of Integer): Integer;
    var
      i, i2, colorsFound : Integer;
    begin
      for i := Low(origColors) to High(origColors) do
        begin
          for i2 := Low(searchColors) to High(searchColors) do
            begin
              if origColors[i] = searchColors[i2] then
                begin
                  colorsFound := colorsFound + 1;
                  Break;
                end;
            end;
        end;
      Result := colorsFound;
    end;
    Muhahaha hewo Stuart its Inf3cti0us looks good i dont think theres difference of Noted and not noted items? looks good to me imo maybe some1 may help and how is it going with the Merchanting bot?

  3. #3
    Join Date
    Jul 2008
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mormonman posted a more effective method on merch forums, I'm looking into just using DTM's until I perfect my methods.

    There are differences with noted and non noted items, I'm looking into alternative ideas though

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

    Default

    Use GetColors rather than multiple GetColor calls

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
  •