Rampant on the Tracks's Track generation logic, leveraging Voronout and optimized for a web service.
Project description
RampantTrackGeneration is..
.. the Track generation logic for Rampant on the Tracks.
The logic is invoked by calling
@staticmethod
def generateTrack(
diagramWidth: int,
diagramHeight: int,
numDiagramRegions: int,
diagramEdgePercentageToProcess: float,
newConnectionAngleMinQuantile: float,
lonelyConnectionMinLengthQuantile: float,
connectionLengthVertexPadding: float,
connectionLengthNodeBuffer: float,
destinationDistanceUpperQuantile: float
) -> Track:
in TrackGenerator.
Track
@dataclass(frozen=True)
class Track:
nodes: dict[uuid4, Point]
stops: dict[uuid4, tuple[Point]]
edges: dict[uuid4, EdgeVertexInfo]
startNode: uuid4
destinationNode: uuid4
describes a set of edges, each a connection between two Points. nodes are the Points - stops are intervals on each edge, a gameplay mechanic that'll be elaborated later.
generateTrack derives the Track from a randomly generated Voronoi diagram.
It preserves the organic appeal of the diagram's shape - connectivity of varying lengths between unevenly spaced points - and goes on to enhance that by removing a subset of the smallest edges, replacing them with longer " reconnections ". The reconnections' intersections with other edges are calculated. Intersections that could be removed without newly isolating either of the involved Points are removed - this, and further trimming, increase the variance of the resulting Track's shape and its appeal in both visual and gameplay terms.
It uses Voronout to generate the diagram and networkX to model the diagram's transformation into a Track.
startNode and destinationNode reflect the gameplay - where the Walker the player is responsible for starts from, and where it must end up for the player to win.
RampantTrackGeneration works by..
.. doing the following:
- generating #
numDiagramRegionsVoronoi diagram sites (0 <= x <= diagramWidth,0 <= y <= diagramHeight) - generating the Voronoi diagram
- using
newConnectionAngleMinQuantileto calculateinitialDiagramMinAcceptableAngle, the minimum angle any new reconnection should make with any of the edges at either of its vertices- rejecting any reconnection that does not satisfy that constraint minimizes the probability of getting
Trackedges that make awkwardly small angles with other edges
- rejecting any reconnection that does not satisfy that constraint minimizes the probability of getting
- reconnecting
diagramEdgePercentageToProcess * 100% of the smallest edges in the diagram - removing all intersection edges created by reconnection that can be safely removed
- removing all " lonely " edges (ones where one vertex is only connected to that edge) with length <=
lonelyConnectionMinLengthQuantile * 100% of all edge lengths - adjusting all edges with length <
minEdgeAdjustLength, either..- .. combining them with another collinear edge such that the combination would make the longest edge possible
- .. deleting the edge, reconnecting all edges involving the vertex with the fewest neighbors to the other vertex
- placing
Stopson the remaining edges- to avoid the awkwardness of placing on " too small edges ", we only place on edges whose length is greater than
(connectionLengthVertexPadding + connectionLengthNodeBuffer) * 100% of edges - to space
Stopsorganically on an edge, we place them at leastconnectionLengthVertexPadding * 100% of the edge length away from either of points - and make the distance between eachStopat leastconnectionLengthNodeBuffer * 100% of the edge length
- to avoid the awkwardness of placing on " too small edges ", we only place on edges whose length is greater than
- calculating
Track.startNodeandTrack.destinationNodePoint.distance(<startNode>, <destinationNode>)must be >=destinationDistanceUpperQuantile * 100% of the distances non-startNodes have tostartNode
The resulting enhancement can be seen in the below illustration of Voronoi diagram -> Track:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rampanttrackgeneration-0.0.1.2.2.tar.gz.
File metadata
- Download URL: rampanttrackgeneration-0.0.1.2.2.tar.gz
- Upload date:
- Size: 4.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e118ee2d6d6ac1a72231f1e59e185f461b4021dc78d846ec293dfe28c595a66a
|
|
| MD5 |
903e9969b0e052ac3da334b150516b84
|
|
| BLAKE2b-256 |
20b261321370def4e8a3ce7c6cde9e546954c6cf197f08fed7d5da736d06b92a
|
File details
Details for the file rampanttrackgeneration-0.0.1.2.2-py3-none-any.whl.
File metadata
- Download URL: rampanttrackgeneration-0.0.1.2.2-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44b8ac3b55b9155b2367cc5d3fe294e68d794d618ccfb4f5a9acdce76deae299
|
|
| MD5 |
6f44d54dcde758afe51d6b3f65e78bd2
|
|
| BLAKE2b-256 |
38494e4f5c2256f399d83fb5249214a23cc8b532e8db63c98f867793951f6085
|