Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How to add a door to a Web?

Joined
Jun 5, 2016
Messages
12
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:
// Get the door coordinate
final Coordinate doorPosition = new Coordinate(####, ####, #);

// Add the door as a BasicObjectVertex
final BasicObjectVertex door = new BasicObjectVertex(doorPosition, "Door", "Open", Collections.emptyList());

// Get the old inputs and outputs from the Door's position
Collection<WebVertex> inputs = web.getVertexOn(doorPosition).getInputs();
Collection<WebVertex> outputs = web.getVertexOn(doorPosition).getOutputs();

// Iterate through the inputs and outputs and add them to the Door vertex
inputs.forEach(door::addDirectedEdge);
outputs.forEach(door::addDirectedEdge);

// Connect the Door to the vertices nearest to it
web.getVertexNearestTo(doorPosition).addBidirectionalEdge(door);

// Finally, add the new object vertices to the web
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.
 
Are bumps allowed? This really needs an answer.
 
( ͡° ͜ʖ ͡°)
Joined
Mar 30, 2015
Messages
2,416
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.
 
Joined
Jun 5, 2016
Messages
12
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.

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:
// Defining positions of the staircases
final Coordinate upstairsPosition = new Coordinate(####, ####, #);   // coordinate when you want to go down the stairs
final Coordinate downstairsPosition = new Coordinate(####, ####, #); // coordinate when you want to go up the stairs

// Making object vertices
final BasicObjectVertex upStairs = new BasicObjectVertex(upstairsPosition, "Staircase", "Climb-down", Collections.emptyList());
final BasicObjectVertex downStairs = new BasicObjectVertex(downstairsPosition, "Staircase", "Climb-up", Collections.emptyList());

// Connect the Staircases
upStairs.addBidirectionalEdge(downStairs);

// Connect the Staircases individually to the vertices nearest to them
web.getVertexNearestTo(upstairsPosition).addBidirectionalEdge(upStairs);
web.getVertexNearestTo(downstairsPosition).addBidirectionalEdge(downStairs);

// Add the new object vertices to the web so finding a path will consider them
web.addVertices(upStairs, downStairs);
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
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.
 
Joined
Jun 5, 2016
Messages
12
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.

I tried that - didn't work.

This is the code I created based on your reply that doesn't work
Code:
final Coordinate doorCoordinate = new Coordinate(3115, 3450, 0);
final WebVertex aboveDoor = web.getVertexOn(new Coordinate(3115, 3451, 0));
final WebVertex belowDoor = web.getVertexOn(new Coordinate(3115, 3449, 0));

final BasicObjectVertex door = new BasicObjectVertex(doorCoordinate, "Door", "Open", Collections.emptyList());

door.addBidirectionalEdge(aboveDoor);
door.addBidirectionalEdge(belowDoor);

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:
CoordinateVertex toRemove = (CoordinateVertex) web.getVertexOn(doorCoordinate);
web.removeVertices(toRemove.getInputs());
web.removeVertices(toRemove.getOutputs());
web.removeVertices(toRemove);
 
Last edited:
Joined
Dec 10, 2014
Messages
3,332
Code:
WebVertex outsideVertex = web.getVertexOn(outside);
WebVertex insideVertex = web.getVertexOn(inside);
if (outsideVertex != null && insideVertex != null) {
    WebVertex objectVertex = new BasicObjectVertex(doorCoordinate, "Door", "Open", Collections.emptyList());
    for (WebVertex out : outsideVertex.getOutputs()) {
        objectVertex.addDirectedEdge(out);
        out.getInputs().remove(outsideVertex);
        out.getInputCosts().remove(outsideVertex);
    }
    for (WebVertex in : outsideVertex.getInputs()) {
        in.addDirectedEdge(objectVertex);
        in.getOutputs().remove(outsideVertex);
        in.getOutputCosts().remove(outsideVertex);
    }
    insideVertex.addBidirectionalEdge(objectVertex);
    web.addVertices(objectVertex);
    web.removeVertices(outsideVertex);
} else {
    System.out.println(outsideVertex);
    System.out.println(insideVertex);
}
 
Last edited:
Go check out new bots and give helpful feedback.
Joined
Jan 31, 2016
Messages
5,413
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:
// Defining positions of the staircases
final Coordinate upstairsPosition = new Coordinate(####, ####, #);   // coordinate when you want to go down the stairs
final Coordinate downstairsPosition = new Coordinate(####, ####, #); // coordinate when you want to go up the stairs

// Making object vertices
final BasicObjectVertex upStairs = new BasicObjectVertex(upstairsPosition, "Staircase", "Climb-down", Collections.emptyList());
final BasicObjectVertex downStairs = new BasicObjectVertex(downstairsPosition, "Staircase", "Climb-up", Collections.emptyList());

// Connect the Staircases
upStairs.addBidirectionalEdge(downStairs);

// Connect the Staircases individually to the vertices nearest to them
web.getVertexNearestTo(upstairsPosition).addBidirectionalEdge(upStairs);
web.getVertexNearestTo(downstairsPosition).addBidirectionalEdge(downStairs);

// Add the new object vertices to the web so finding a path will consider them
web.addVertices(upStairs, downStairs);
Hope you dont mind if i use this :D
It helps a lot!
 
Top