logoHome

Castle Jump

Markov Process-Based Platform Generation

Gaussian Distribution

The initial design uses a Gaussian distribution to determine platform placement, with the mean set at the previous platform position. The varianceincreases via a predefined schedule to ramp difficulty. We sample with the Box–Muller transform and then shift/scale to μ\mu and σ2\sigma^2.

Z0=2lnU1cos(2πU2)Z1=2lnU1sin(2πU2)Z_0 = \sqrt{-2\ln U_1}\,\cos(2\pi U_2) \\ Z_1 = \sqrt{-2\ln U_1}\,\sin(2\pi U_2)

where U1,U2Uniform(0,1)U_1, U_2 \sim \mathrm{Uniform}(0,1). Extremes can place platforms out of view.

Clipped Gaussian Distribution

Clipping out-of-range samples to boundaries causes mass to accumulate at edges, especially when the prior platform is near a viewport boundary.

Rejection Sampling

Discard invalid samples until a valid one appears. Straightforward but no longer constant-time as rejection probability grows.

Truncated Gaussian Distribution

Sample via the inverse CDF. Since the Gaussian CDF is intractable, write it with the error function and use efficient approximations.

Φ(0,1;x)=x12πet2/2dt=12+12erf ⁣(x2)\begin{aligned} \Phi(0,1;x) &= \int_{-\infty}^{x} \frac{1}{\sqrt{2\pi}} e^{-t^{2}/2}\,dt \\ &= \frac{1}{2} + \frac{1}{2}\,\operatorname{erf}\!\left(\frac{x}{\sqrt{2}}\right) \end{aligned}

where erf(x)=1πxxet2dt\operatorname{erf}(x) = \frac{1}{\sqrt{\pi}}\int_{-x}^{x} e^{-t^{2}}\,dt.

Error Function Approximations

  1. Maclaurin — accurate near 0 only.
  2. Taylor — many anchors needed.
  3. Abramowitz & Stegun — constant time/space.

Inverse Error Function

  • Winitzki — fast erf−1 approximation.

Effective numerically, but results cluster near the previous platform—often undesirable for game feel.

Bimodal Truncated Gaussian

Use a bimodal truncated Gaussian to reduce consecutive platforms near the same spot. Weights adjust with previous platform position (e.g., first quartile → left 25%, right 75%).