Track Designer
Create valid track layouts for GridRacer.
Track Requirements (from design doc)
Cell Types
swift
enum CellType {
case track // Valid racing surface
case wall // Collision boundary
case start // Starting area
case finish // Finish line area
}
Track Structure
swift
struct Track {
let width: Int
let height: Int
let cells: [[CellType]]
let startPositions: [GridPoint]
let finishLine: LineSegment
let lapCount: Int
}
Design Guidelines
- •Closed loop: Track must form a complete circuit
- •Width: Minimum 2 cells wide for passing
- •Start positions: Staggered, equal distance to first turn
- •Finish line: Perpendicular to track direction
- •Corners: Allow multiple racing lines
- •Balance: Fair for all starting positions
Example: Simple Oval (10x8)
code
.......... .########. .#......#. .#......#. .S......F. .#......#. .#......#. .########. ..........
Legend: .=wall, #=track, S=start, F=finish
Output Format
Generate Swift code for the track:
swift
let simpleOval = Track(
width: 10,
height: 8,
cells: [...],
startPositions: [GridPoint(2, 4), GridPoint(2, 3)],
finishLine: LineSegment(start: GridPoint(8, 3), end: GridPoint(8, 5)),
lapCount: 3
)