Skip to content

Change randomization scheme #101

Description

@trevorld

❯ My Portable Piecepack Notation (PPN) can (for a subset of games) generate random board game setups given a seed. Currently it is written in R but if some third party wanted to implement this notation in another language I was trying to figure out how hard it would be to match such setups.

● This is a design question about the PPN spec itself. The core problem is that "use the language's native RNG seeded with X" is not a portable specification — even if both R and Python use Mersenne Twister, R's set.seed() initialization and sample() sampling algorithm differ from numpy's in ways that are tedious to replicate.

You have two realistic paths:
Option 1: Specify a portable RNG in the PPN spec
Define the shuffle algorithm explicitly so any implementor can match it without reimplementing R internals. A good choice is a small, well-documented RNG + Fisher-Yates. For example, PCG32 or xorshift64 are each ~10 lines to implement in any language. The spec would say "initialize PCG32 with seed X, then apply Fisher-Yates" and every implementation matches exactly.
Option 2: Accept non-portability and document it
If you're comfortable that PPN setups are only reproducible within R (i.e., a seed in a PPN file is only meaningful to R implementations), document that clearly and move on. A third-party Python implementation would just use its own native RNG and the same seed would produce a different-but-valid random setup.
The practical tradeoff: Option 1 adds a small upfront spec burden but makes PPN setups truly portable and archivable — a PPN file with a seed is self-contained regardless of language. Option 2 is simpler now but means a seed embedded in a PPN file is R-specific, which could be surprising to users.
Given that PPN is a notation format (implying long-term archival and interoperability), Option 1 seems like the right call if random setups are a meaningful part of the spec. The implementation cost in any language is small — PCG32 is about 15 lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions