Results 1 to 9 of 9

Thread: Need help with script (Newbie)

  1. #1
    Join Date
    Feb 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need help with script (Newbie)

    EDIT: Wrong section, sorry! Move if you must


    Ok, so I am beginning to work on a script for the game some are familiar with (Puzzle Pirates) and I am having trouble thinking of what to write for a part in my script.

    First off

    Here is a "good board":


    I have defined a "good board" as a board with the red region to be empty of the crates that are randomly generated on the board. (Showed in blue)

    What I want to do is find out how I can make my bot do my procedure until there is a good board displayed.

    Code:
     procedure CheckBoard;
       var x, y: integer;
      begin
       PlainCrate := DTMFromString('mQwAAAHicY2ZgYBBlZGDQA2J1IH4KxP+B+BMQL2pKYghys2RY2BDLgAwYkTAQAAAitwci');
       RockCrate := DTMFromString('mLgAAAHicY2JgYNgNxVxMDAwSQKwiL8qwZFoHAwwwQjEDAwBtVwO7');
       RedCrate := DTMFromString('mLgAAAHicY2JgYHgNxPeAmJuRgUGaEcKezQhkQAEjFDMwAABxAQNx');
    
    
    
        if FindDTM(PlainCrate, x, y, 19, 441, 443, 487) = true then
         begin
          Abandon;      // a previously defined procedure that exits the board
          FindCannon;   // procedure that opens new puzzle board
        end;
    
        if FindDTM(RedCrate, x, y, 19, 441, 443, 487) = true then
         begin
          Abandon;
          FindCannon;
        end;
    
        if FindDTM(RockCrate, x, y, 19, 441, 443, 487) = true then
        begin
         Abandon;                              
         FindCannon;
        end;
    
    
        FreeDTM(PlainCrate);
        FreeDTM(RockCrate);
        FreeDTM(RedCrate);
      end;

    The DTM's in my script are the 3 randomly generated crates, one being the crate full of rocks, one being the box with berries, etc.

    So, my bot will open a board, and check the board if it has any crates in the red region. If there are any crates in the region, it will abandon the puzzle board and re open it. It stops after the second try. Sometimes it takes about 4-5 tries to get a good board, so i need to find out how to make my procedure continue abandoning multiple times until it has a good board.

    If you understood this load of crap i just wrote, any help is appreciated. thanks
    Last edited by Saltyspoons; 06-06-2012 at 08:56 AM.

  2. #2
    Join Date
    Dec 2011
    Posts
    183
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Simba Code:
    procedure CheckBoard;
       var x, y: integer;
      begin
       PlainCrate := DTMFromString('mQwAAAHicY2ZgYBBlZGDQA2J1IH4KxP+B+BMQL2pKYghys2RY2BDLgAwYkTAQAAAitwci');
       RockCrate := DTMFromString('mLgAAAHicY2JgYNgNxVxMDAwSQKwiL8qwZFoHAwwwQjEDAwBtVwO7');
       RedCrate := DTMFromString('mLgAAAHicY2JgYHgNxPeAmJuRgUGaEcKezQhkQAEjFDMwAABxAQNx');

    if (goodboard)then
    begin
    exit; //this will exit out of the procedure onto the next procedure on the mainloop. feel free to change to whatever
    end;
    repeat
        if FindDTM(PlainCrate, x, y, 19, 441, 443, 487) then
         begin
          Abandon;      // a previously defined procedure that exits the board
          FindCannon;   // procedure that opens new puzzle board
        end;

        if FindDTM(RedCrate, x, y, 19, 441, 443, 487) then
         begin
          Abandon;
          FindCannon;
        end;

        if FindDTM(RockCrate, x, y, 19, 441, 443, 487) then
        begin
         Abandon;                              
         FindCannon;
        end;

    until (goodboard)


        FreeDTM(PlainCrate);
        FreeDTM(RockCrate);
        FreeDTM(RedCrate);
      end;

    this maybe? not to sure though

    edit:actually i think my example wont work. ill wait till tomorrow

  3. #3
    Join Date
    Feb 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by zluo View Post

    this maybe? not to sure though

    edit:actually i think my example wont work. ill wait till tomorrow
    This is good help.

    I don't know how to define what a "good board" is to simba. Would I declare a Boolean variable named goodboard, and make it "if there aren't any DTM's in the region, then goodboard = true"? I wouldn't know how to write that either. I think I am confusing myself, so I will stop writing but thanks and let me know if you think of something tomorrow.
    Last edited by Saltyspoons; 06-06-2012 at 09:30 AM.

  4. #4
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Simba Code:
    function GoodBoard : Boolean;
    begin
      Result:= not FindColor(X, Y, CrateColour, X1, Y1, X2, Y2);
    end;
    That would do the same job?
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  5. #5
    Join Date
    Dec 2011
    Posts
    183
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    actually come to think of it, it can be very simple. you dont actually need those box dtms, just make a dtm of the entire good board(make sure you put dtm marks where the boxes are usually are so it can be spotted) and if (goodboard) = false then abandon.
    if(goodboard)=true then carry on

  6. #6
    Join Date
    Feb 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Based on all your guys' input, my problem is 100% solved!

    Here is the final code (Credit to zluo and Rich):

    Simba Code:
    procedure CheckBoard;
       var x, y, GoodBoard: Integer;
       begin
        GoodBoard := DTMFromString('maQEAAHicE2RgYFjMyMDQDMRJQOwExIpAzAvE34Fyj4H4HBDvAOJFQNwDxGVAnAzEvkBsDsRKQHwdqP4GFN8E4ltAfBuKb0BpZPE7UPoeEN+Fii+s8mFYWOLDsLjSl2FhuQ/DsroQhnklHgzLqgMYFlb6AcV8IWyg3JIyN4bFFb5gsaW1wQwrGyMYmhLtGKgBGKmAMQAAezcuew==');
        If FindDTM(GoodBoard, x, y, 19, 441, 443, 487) = false then
        repeat
        begin
        Abandon;
        FindCannon;
        end;
        until FindDTM(GoodBoard, x, y, 19, 441, 443, 487) = true;
       end;


    Edit: Spelling

  7. #7
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by Saltyspoons View Post
    Based on all your guys' input, my problem is 100% solved!

    Here is the final code (Credit to zluo and Rich):

    Simba Code:
    procedure CheckBoard;
       var x, y, GoodBoard: Integer;
       begin
        GoodBoard := DTMFromString('maQEAAHicE2RgYFjMyMDQDMRJQOwExIpAzAvE34Fyj4H4HBDvAOJFQNwDxGVAnAzEvkBsDsRKQHwdqP4GFN8E4ltAfBuKb0BpZPE7UPoeEN+Fii+s8mFYWOLDsLjSl2FhuQ/DsroQhnklHgzLqgMYFlb6AcV8IWyg3JIyN4bFFb5gsaW1wQwrGyMYmhLtGKgBGKmAMQAAezcuew==');
        If FindDTM(GoodBoard, x, y, 19, 441, 443, 487) = false then
        repeat
        begin
        Abandon;
        FindCannon;
        end;
        until FindDTM(GoodBoard, x, y, 19, 441, 443, 487) = true;
       end;


    Edit: Spelling
    Simba Code:
    procedure CheckBoard;
    var
      X, Y, GoodBoard : Integer;

    begin
      GoodBoard:= DTMFromString('maQEAAHicE2RgYFjMyMDQDMRJQOwExIpAzAvE34Fyj4H4HBD' +
                  'vAOJFQNwDxGVAnAzEvkBsDsRKQHwdqP4GFN8E4ltAfBuKb0BpZPE7UPoeEN+Fi' +
                  'is8mFYWOLDsLjSl2FhuQ/DsroQhnklHgzLqgMYFlb6AcV8IWyg3JIyN4bFFb5g' +
                  'saW1wQwrGyMYmhLtGKgBGKmAMQAAezcuew==');
      if not FindDTM(GoodBoard, X, Y, 19, 441, 443, 487) then
      repeat
        Abandon;
        FindCannon;
      until FindDTM(GoodBoard, X, Y, 19, 441, 443, 487);
    end;
    Couldn't help myself
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  8. #8
    Join Date
    Feb 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    Couldn't help myself
    hahahaha. I had just done the standards on my client, but not on my post. I forgot how much Simba hates ugly code. But actually, I never thought about using '+' signs for those long DTM's. Don't feel bad because you really taught me something here!!

  9. #9
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Haha no problem, glad I could help out then.
    One thing I just remembered is that you might need to put + signs at the start of the lines as well, like this
    Simba Code:
    + 'vAOJFQNwDxGVAnAzEvkBsDsRKQHwdqP4GFN8E4ltAfBuKb0BpZPE7UPoeEN+Fi' +
    + 'is8mFYWOLDsLjSl2FhuQ/DsroQhnklHgzLqgMYFlb6AcV8IWyg3JIyN4bFFb5g' +
    + 'saW1wQwrGyMYmhLtGKgBGKmAMQAAezcuew==');
    I can't be too sure though, but if one way gives you an error, try to other way
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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