Skip to main content
added 36 characters in body
Source Link
Lighthink
  • 473
  • 4
  • 11

If you have rooms and corridors separated by walls and inter-connected by doors you can assume each door is a node in a graph. The door-graph can be pre-computed, with costs equal to the distance between the doors. You updatecreate a cost graph, including the minimum costs from the janitor to each door-graph with current values, based on the current position of the janitor and the constant distances between the doors. Then for each pile of trash, you check all the doors in the same room and pick the minimum cost (that cost is the distance from the janitor to that door + the distance from the pile of trash to that door). After that, you just pick the pile of trash with the minimum cost.

It is still a path-finding algorithm, but I think it will work pretty fast, even for massive amounts of data, but I don't think one janitor can clean that much trash :).

Hope it helps.

If you have rooms and corridors separated by walls and inter-connected by doors you can assume each door is a node in a graph. The door-graph can be pre-computed, with costs equal to the distance between the doors. You update the door-graph with current values, based on the current position of the janitor and the constant distances between the doors. Then for each pile of trash, you check all the doors in the same room and pick the minimum cost (that cost is the distance from the janitor to that door + the distance from the pile of trash to that door). After that, you just pick the pile of trash with the minimum cost.

It is still a path-finding algorithm, but I think it will work pretty fast, even for massive amounts of data, but I don't think one janitor can clean that much trash :).

Hope it helps.

If you have rooms and corridors separated by walls and inter-connected by doors you can assume each door is a node in a graph. The door-graph can be pre-computed, with costs equal to the distance between the doors. You create a cost graph, including the minimum costs from the janitor to each door based on the current position of the janitor and the constant distances between the doors. Then for each pile of trash, you check all the doors in the same room and pick the minimum cost (that cost is the distance from the janitor to that door + the distance from the pile of trash to that door). After that, you just pick the pile of trash with the minimum cost.

It is still a path-finding algorithm, but I think it will work pretty fast, even for massive amounts of data, but I don't think one janitor can clean that much trash :).

Hope it helps.

Source Link
Lighthink
  • 473
  • 4
  • 11

If you have rooms and corridors separated by walls and inter-connected by doors you can assume each door is a node in a graph. The door-graph can be pre-computed, with costs equal to the distance between the doors. You update the door-graph with current values, based on the current position of the janitor and the constant distances between the doors. Then for each pile of trash, you check all the doors in the same room and pick the minimum cost (that cost is the distance from the janitor to that door + the distance from the pile of trash to that door). After that, you just pick the pile of trash with the minimum cost.

It is still a path-finding algorithm, but I think it will work pretty fast, even for massive amounts of data, but I don't think one janitor can clean that much trash :).

Hope it helps.