fictiveworks / CalyxSharp

Generative text processing for C# and Unity applications
Other
0 stars 0 forks source link

Support unique cycle nodes and expression syntax #4

Closed maetl closed 1 year ago

maetl commented 2 years ago

Feature

Support unique cycle nodes and expression syntax. This allows rule expansions to cycle through evaluating each possible branch until reaching

Syntax

Cycles are embedded as template expressions using the $ sigil as a prefix.

{
  "start": "{$medal}",
  "medal": ["gold", "silver", "bronze"]
}

Implementation

Requires adding a Uniq syntax node class and some additional processing to the registry.

Previous implementations expanded a unique rule symbol by evaluating it and checking that it hadn’t previously been selected. This is poorly designed and doesn’t guarantee halting, so it would be nice to improve the algorithm rather than re-implement is as-is (presumably with a bit of temp state storage).

Edge Cases & Specification

  1. Unique rules cycle once sequence is consumed. See the original test spec.
  2. Each cycle should pick elements randomly from the set of branches, rather than repeating the first cycle over and over.
maetl commented 2 years ago

The work done in #5 goes some way towards this, but I can’t remember exactly what I did or how far I got with testing, so will need to go through it step by step.

maetl commented 1 year ago

Looks like this is complete for now. I will confirm and close this once I have a couple of end-to-end tests working.