Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/physics0/regime/pd0_regime.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / physics0 / regime / pd0_regime.c` 36 lines ยท 1632 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* PD-0 dev-only regime switch. See pd0_regime.h. */ 18 #include "physics0/regime/pd0_regime.h" 19 20 #include 21 22 int pd0_world_switch_regime(pd0_world *w, int level, uint32_t regime, int64_t *max_change_ppm) 23 { 24 if (regime == 0) return -1; 25 pd0_gen ng; 26 for (uint32_t attempt = 0; attempt < 16; attempt++) { /* an invalid L6 draw (redraw cap) is skipped */ 27 uint64_t s = w->seed ^ ((uint64_t)(regime + attempt * 977u) * 0x9E3779B97F4A7C15ull); 28 if (pd0_gen_init(&ng, level, s) != 0) continue; 29 int64_t worst = 0; const pd0_crange *t; int n = pd0_gen_const_table(level, &t); 30 for (int i = 0; i < n; i++) { int64_t o = w->gen.k[i], d = llabs(ng.k[i] - o); int64_t ppm = o ? (int64_t)((double)d * 1e6 / (double)(o < 0 ? -o : o)) : 0; if (ppm > worst) worst = ppm; } 31 w->gen = ng; w->in_episode = 0; w->steps_used = 0; w->episodes_used = 0; 32 if (max_change_ppm) *max_change_ppm = worst; 33 return 0; 34 } 35 return -1; 36 }