Skip to main content

RampantTrackGeneration is..

.. the Track generation logic for Rampant on the Tracks.

The logic is invoked by calling

@staticmethod
  def generateTrack(
      diagramWidth: int,
      diagramWidthOffset: float,
      diagramHeight: int,
      diagramHeightOffset: float,
      diagramNodeRadius: float,
      numDiagramRegions: int,
      diagramEdgePercentageToProcess: float, 
      newConnectionAngleMinQuantile: float, 
      lonelyConnectionMinLengthQuantile: float, 
      connectionLengthVertexPadding: float, 
      connectionLengthNodeBuffer: float,
      destinationDistanceUpperQuantile: float
  )

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,
    nodeInfo: dict[uuid4, NodeInfo]

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.

nodeInfo maps nodes to further information about them

@dataclass(frozen=True)
class NodeInfo:
    distanceToDestination: float
    numNeighbors: int

that the game logic needs.

RampantTrackGeneration works by..

.. doing the following:

  • generating #numDiagramRegions Voronoi diagram sites (0 <= x <= diagramWidth, 0 <= y <= diagramHeight)
  • generating the Voronoi diagram
  • offsetting the diagram with regards to frontend display constraints (diagramWidthOffset, diagramHeightOffset, diagramNodeRadius)
  • using newConnectionAngleMinQuantile to calculate initialDiagramMinAcceptableAngle, 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 Track edges that make awkwardly small angles with other edges
  • 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
  • adjusting all nodes too close to other edges or nodes (length between < diagramNodeRadius * 2)
    • Edges: Extending the segments to which the node is connected to intersect with the too-close edge (and deleting any intersection edges where length between < minEdgeAdjust)
    • Nodes: Taking each (node, otherNode) pair where one is too close to the other, picking the one with less neighbors, and reconnecting those neighbors to the other node to create longer edges.
  • adjusting node positions so that they fall within frontend display constraints
  • placing Stops on 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 Stops organically on an edge, we place them at least connectionLengthVertexPadding * 100% of the edge length away from either of points - and make the distance between each Stop at least connectionLengthNodeBuffer * 100% of the edge length
  • calculating Track.startNode and Track.destinationNode
    • Point.distance(<startNode>, <destinationNode>) must be >= destinationDistanceUpperQuantile * 100% of the distances non-startNodes have to startNode
  • calculating Track.nodeInfo

The resulting enhancement can be seen in the below illustration of Voronoi diagram -> Track:

GIF visualizing TrackGeneration.generateTrack()

Metadata

Release files for RampantTrackGeneration 0.0.1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RampantTrackGeneration 0.0.1.3.0
File Size Uploaded Provenance Actions
rampanttrackgeneration-0.0.1.3.0.tar.gz 4.1 MB Without provenance Details for rampanttrackgeneration-0.0.1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for RampantTrackGeneration 0.0.1.3.0
File Interpreter ABI Platform Actions
rampanttrackgeneration-0.0.1.3.0-py3-none-any.whl Python 3 none any Details for rampanttrackgeneration-0.0.1.3.0-py3-none-any.whl

Total release size: 4.2 MB

Release files / rampanttrackgeneration-0.0.1.3.0.tar.gz

Download URL rampanttrackgeneration-0.0.1.3.0.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
90e6367956bbdc8cd01e6b36a90eab52db2b1f3c1b8eb504cf023525c2cd7b21
BLAKE2b-256 checksum
How to use checksums
92c8bb8f6114abce2e3fb98413fe39f1eebd59cb8f1d267579a5b19c314183e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / rampanttrackgeneration-0.0.1.3.0-py3-none-any.whl

Download URL rampanttrackgeneration-0.0.1.3.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a6a2733fe03159a71ce023c8cd0b58fa4b5f4a15c5a3f7773f990c75a3e7527
BLAKE2b-256 checksum
How to use checksums
fc149dfa48332ec18a341b5f73c785c6c34c323444bddb99690181c5b5ad6d91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for RampantTrackGeneration 0.0.1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page