1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question How to add a door to a Web?

Discussion in 'Developer Support' started by ChosenBotter, Jun 12, 2016.

  1. ChosenBotter

    Joined:
    Jun 5, 2016
    Messages:
    12
    Likes Received:
    3
    I'm trying to have my bot path to something in a house, which can require opening a door.

    For this particular bot, I also had to add a staircase to my web, and was able to do so successfully. However, my bot struggles with doors. This is what I have so far in my attempt. Note that the Web object I'm using was generated from a .nav file, which was generated when the door was closed.

    Code (Text):
    1. // Get the door coordinate
    2. final Coordinate doorPosition = new Coordinate(####, ####, #);
    3.  
    4. // Add the door as a BasicObjectVertex
    5. final BasicObjectVertex door = new BasicObjectVertex(doorPosition, "Door", "Open", Collections.emptyList());
    6.  
    7. // Get the old inputs and outputs from the Door's position
    8. Collection<WebVertex> inputs = web.getVertexOn(doorPosition).getInputs();
    9. Collection<WebVertex> outputs = web.getVertexOn(doorPosition).getOutputs();
    10.  
    11. // Iterate through the inputs and outputs and add them to the Door vertex
    12. inputs.forEach(door::addDirectedEdge);
    13. outputs.forEach(door::addDirectedEdge);
    14.  
    15. // Connect the Door to the vertices nearest to it
    16. web.getVertexNearestTo(doorPosition).addBidirectionalEdge(door);
    17.  
    18. // Finally, add the new object vertices to the web
    19. web.addVertices(door);
    Also, please note that I've tried running my bot using a Web object generated from a .nav with the door open (as opposed to with the door closed), and both attempts were unsuccessful.

    Also, please note that this is in OSRS, so while the new RS3 web is awesome, it doesn't help me here.
    --- Double Post Merged, Jun 12, 2016, Original Post Date: Jun 8, 2016 ---
    Are bumps allowed? This really needs an answer.
     
    awesome123man likes this.
  2. Serene

    Serene ( ͡° ͜ʖ ͡°)

    Joined:
    Mar 30, 2015
    Messages:
    2,408
    Likes Received:
    508
    If you can't find a way to add a door, you could always split the web up into two and find the door as a gameobject, and interact with it in between.

    How did you add staircase interactions? As of now, I'm having a problem with interacting with ladders.
     
  3. ChosenBotter

    Joined:
    Jun 5, 2016
    Messages:
    12
    Likes Received:
    3
    I can do what you said, but it's annoying to do and is not personally an acceptable solution - it just feels "hacky".

    Also, as for implementation of a staircase, this is my code (ladder should be very similar). Note that the coordinates are the coordinate that the staircase occupies (just thought I'd make that clear).

    Code (Text):
    1. // Defining positions of the staircases
    2. final Coordinate upstairsPosition = new Coordinate(####, ####, #);   // coordinate when you want to go down the stairs
    3. final Coordinate downstairsPosition = new Coordinate(####, ####, #); // coordinate when you want to go up the stairs
    4.  
    5. // Making object vertices
    6. final BasicObjectVertex upStairs = new BasicObjectVertex(upstairsPosition, "Staircase", "Climb-down", Collections.emptyList());
    7. final BasicObjectVertex downStairs = new BasicObjectVertex(downstairsPosition, "Staircase", "Climb-up", Collections.emptyList());
    8.  
    9. // Connect the Staircases
    10. upStairs.addBidirectionalEdge(downStairs);
    11.  
    12. // Connect the Staircases individually to the vertices nearest to them
    13. web.getVertexNearestTo(upstairsPosition).addBidirectionalEdge(upStairs);
    14. web.getVertexNearestTo(downstairsPosition).addBidirectionalEdge(downStairs);
    15.  
    16. // Add the new object vertices to the web so finding a path will consider them
    17. web.addVertices(upStairs, downStairs);
     
    Serene likes this.
  4. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Generate a web which has the door blocking the coordinate. Then, create a BasicObjectVertex as you did above. Get the links on both sides of the web and add a bidirectional edge connecting the created BasicObjectVertex to both. Then add that BasicObjectVertex to the web.
     
  5. ChosenBotter

    Joined:
    Jun 5, 2016
    Messages:
    12
    Likes Received:
    3
    I tried that - didn't work.

    This is the code I created based on your reply that doesn't work
    Code (Text):
    1. final Coordinate doorCoordinate = new Coordinate(3115, 3450, 0);
    2. final WebVertex aboveDoor = web.getVertexOn(new Coordinate(3115, 3451, 0));
    3. final WebVertex belowDoor = web.getVertexOn(new Coordinate(3115, 3449, 0));
    4.  
    5. final BasicObjectVertex door = new BasicObjectVertex(doorCoordinate, "Door", "Open", Collections.emptyList());
    6.  
    7. door.addBidirectionalEdge(aboveDoor);
    8. door.addBidirectionalEdge(belowDoor);
    9.  
    10. web.addVertices(door);
    EDIT: Also, based on your (Cloud's) Slack answer to remove connecting edges, I wasn't really sure how to do that. This is what I added, and it didn't make the Web work. Did I misunderstand you?
    Code (Text):
    1. CoordinateVertex toRemove = (CoordinateVertex) web.getVertexOn(doorCoordinate);
    2. web.removeVertices(toRemove.getInputs());
    3. web.removeVertices(toRemove.getOutputs());
    4. web.removeVertices(toRemove);
     
    #5 ChosenBotter, Jun 13, 2016
    Last edited: Jun 13, 2016
  6. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,198
    Likes Received:
    1,041
    Code (Text):
    1. WebVertex outsideVertex = web.getVertexOn(outside);
    2. WebVertex insideVertex = web.getVertexOn(inside);
    3. if (outsideVertex != null && insideVertex != null) {
    4.     WebVertex objectVertex = new BasicObjectVertex(doorCoordinate, "Door", "Open", Collections.emptyList());
    5.     for (WebVertex out : outsideVertex.getOutputs()) {
    6.         objectVertex.addDirectedEdge(out);
    7.         out.getInputs().remove(outsideVertex);
    8.         out.getInputCosts().remove(outsideVertex);
    9.     }
    10.     for (WebVertex in : outsideVertex.getInputs()) {
    11.         in.addDirectedEdge(objectVertex);
    12.         in.getOutputs().remove(outsideVertex);
    13.         in.getOutputCosts().remove(outsideVertex);
    14.     }
    15.     insideVertex.addBidirectionalEdge(objectVertex);
    16.     web.addVertices(objectVertex);
    17.     web.removeVertices(outsideVertex);
    18. } else {
    19.     System.out.println(outsideVertex);
    20.     System.out.println(insideVertex);
    21. }
     
    #6 SlashnHax, Jun 13, 2016
    Last edited: Jun 13, 2016
    ChosenBotter likes this.
  7. awesome123man

    awesome123man Go check out new bots and give helpful feedback.

    Joined:
    Jan 31, 2016
    Messages:
    5,413
    Likes Received:
    1,662
    Hope you dont mind if i use this :D
    It helps a lot!
     

Share This Page

Loading...