Skip to content

Instantly share code, notes, and snippets.

@l-Luna
Last active August 19, 2022 09:38
Show Gist options
  • Save l-Luna/22a2595755f11d2acf0409f755cea9bb to your computer and use it in GitHub Desktop.
Save l-Luna/22a2595755f11d2acf0409f755cea9bb to your computer and use it in GitHub Desktop.
Opus Magnum's cycle order

At the start of a cycle,

  1. Grab and Drop instructions are executed
  2. Glyphs are updated (start of cycle)
  3. All other instructions are executed
  4. Collisions are checked

At the end of a cycle,

  1. Glyphs are updated (end of cycle)
  2. Area is measured
  3. The cycle count is updated

In that order. Glyphs are updated twice, but different things may occur at the start and end:

  • If a Purification, Animismus, Unification, or Dispersial can accept their input at the start of a cycle and have not already done so, it does so. If they have previously accepted an input in that cycle (impossible for the start of a cycle), they will produce their output.
  • A conduit accepts a molecule at the start of the cycle and produces it at the end.

Otherwise, the start and end of a cycle is treated the same. Bonds can be made twice in a cycle, atoms can be disposed twice, reagents produce an atom twice if there is space to do so, and projection can project twice in a cycle. An overlapped Quicksilver input and Projection glyph will project twice in a cycle for that reason.

Collisions are checked multiple times per cycle. Movements are stepped forward by some fraction of a cycle n, starting at n. By default, n = 0.1 (10 collisions checks in a cycle), so collision is checked at 0.1, 0.2, 0.3... 1 cycle in (end of cycle).

If a rotation occurs, n may be smaller. n for any particular cycle = min(0.1, 0.25 / dist), where dist = the distance of the atom furthest to its point of rotation to its point of rotation. Any rotation longer than 3 atoms will cause more strict checks, and longer rotations lead to stricter checks.

Editor's note: the time taken to check collisions is logged. I assume this required some optimization at some point.

Editor's second note: n is stored as a C# float. Swinging a molecule 1.67 * 10^45 atoms long will round n to 0 and make an infinite loop. Wolfram Alpha compares this length to the number of chess positions that exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment