/Bolt-Routing-Problem-V2

Piston Bolt Network Builder for Minecraft

Primary LanguageVueMIT LicenseMIT

Piston Bolt Network Builder for Minecraft v2 (WIP)

Online piston bolt network generator and editor

This is an updated web version of an old project of mine. With all the new development in piston bolt tech old servers might consider rebuilding their piston bolt network in the nether. Thus, a good question arise, what is the right way to do it?

When you already know where the stations will be, it comes down to multi-objective optimization problem of how to connect all stations with piston bolts in a way that will minimize both total piston bolt length and the average piston bolt travel time between any set of two stations. This means that the solution lies somewhere on the Pareto frontier.

image

Piston bolt network of Dugged

Sections

Problem domain
Star graph
Complete graph
Minimum spanning tree (MST)
Steiner tree
Distance matrix heatmap
Pareto front
How to use

Problem Domain

Generalizing and looking outside the Minecraft, this problem comes down to finding an optimal interconnect for a given set of vertices (stations) on a 2 dimensional Chebyshev metric space. The solution to the problem is a weighted directed/undirected graph. Weight will be Chebyshev distance between vertices (stations) and directionality would come down to the fact that the graph has loops or not. For example, [Hamiltonian path] can be directed, since in theory a player can get to any station from any station just by traveling in one direction.

1. Star graph

Star graph is a type of tree graph with one internal node and k leaves. You can place the internal node at any arbitrary location, however median or average coordinates of all stations work the best.

image

2. Complete graph

Complete graph is an undirected graph in which every pair of distinct vertices is connected by a unique edge. This gives theoretically shortest amount of average travel time.

image

3. Minimum spanning tree (MST)

MST is a subset of the edges of a connected, weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight.

3.1. Nearest neighbor (NN)

NN is a quick approximation to finding out true MST. The graph this algorithm produces is directed and weighted. Worth mentioning that in the given set of points there are intersections between edges. My implementation is missing one optimization, when detecting line intersections -> switch end points of intersecting lines to get a new, smaller graph.

image

3.2. Hamiltonian cycle

Hamiltonian path is a loop graph that visits each vertex exactly once.

image

3.3. Prim's algorithm

Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph.

image

3.4 Kruskal's algorithm

Kruskal's algorithm finds MST of an undirected edge-weighted graph.

image

4. Steiner tree

Steiner tree problem consists of finding the minimum tree that includes specific points and, if necessary, uses a number of auxiliary points to minimize the tree length (unlike MST). This problem is NP-hard, however heuristic solution exists.

Distance matrix heatmap

To calculate average travel time in a given network I use Floyd-Warshall algorithm that generates this matrix of shortest path between any set of points.

image

Pareto front

To choose a network that best suits your needs, there is a page with scatter plot and Pareto front.

image

How to use

This section is work in progress.

Example network JSON:

{
    "stations": [
        {
            "name": "Station A",
            "description": "This is station A",
            "colour": "#f2a788",
            "x": 0,
            "z": 0
        },
        {
            "name": "Station B",
            "description": "This is station B",
            "colour": "#f2a788",
            "x": 10,
            "z": 30
        }
    ],
    "bolts": [
        {
            "directed": false,
            "station_a": {
                "name": "Station A",
                "x": 0,
                "z": 0
            },
            "turn": {
                "x": 10,
                "z": 10
            },
            "station_b": {
                "name": "Station B",
                "x": 10,
                "z": 30
            },
            "length": 30,
            "colour": "#8f7f10"
        }
    ]
}

License

This program is licensed under the MIT License. Please read the License file to know about the usage terms and conditions.