wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run

ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 5ffe50ed02
commit 19fcf60599
459 changed files with 17862 additions and 17603 deletions

View file

@ -1,16 +1,14 @@
# ranges.ludic - a species keeps to discs placed once, against the ground, 120-700 m out from where
# the valley starts; each winters lower, toward the timber, as far down as it summered high
var wl_ranges: []WildRange = null
var wl_found: []int = null # found flags a load brought before the ranges were set out
export function wildlife_ranges() -> []WildRange {
if wl_ranges == null { wl_ranges = new []WildRange }
return wl_ranges
export function wildlife_ranges(wildlife_st: mut WildlifeState) -> []WildRange {
if wildlife_st.wl_ranges == null { wildlife_st.wl_ranges = new []WildRange }
return wildlife_st.wl_ranges
}
export function wildlife_range(i: int) -> WildRange {
if i < 0 or i >= len(wildlife_ranges()) { return null }
return wildlife_ranges()[i]
export function wildlife_range(wildlife_st: mut WildlifeState, i: int) -> WildRange {
if i < 0 or i >= len(wildlife_ranges(wildlife_st)) { return null }
return wildlife_ranges(wildlife_st)[i]
}
export function wildlife_range_dist(r: WildRange, x: float, z: float) -> float {
@ -19,42 +17,42 @@ export function wildlife_range_dist(r: WildRange, x: float, z: float) -> float {
return Math.sqrt(dx * dx + dz * dz)
}
function wl_range_clashes(sp: int, x: float, z: float) -> bool {
let rs = wildlife_ranges()
for j in 0 .. len(rs) { if rs[j].sp == sp and wildlife_range_dist(rs[j], x, z) < wl_sp(sp).range * 1.6 { return true } }
function wl_range_clashes(wildlife_st: mut WildlifeState, sp: int, x: float, z: float) -> bool {
let rs = wildlife_ranges(wildlife_st)
for j in 0 .. len(rs) { if rs[j].sp == sp and wildlife_range_dist(rs[j], x, z) < wl_sp(wildlife_st, sp).range * 1.6 { return true } }
return false
}
function wl_range_try(sp: int, x0: float, z0: float) -> bool {
let s = wl_sp(sp)
function wl_range_try(wildlife_st: mut WildlifeState, sp: int, x0: float, z0: float) -> bool {
let s = wl_sp(wildlife_st, sp)
for tries in 0 .. 80 {
if not wildlife_find_spot(s.habitat, x0, z0, 120.0, 700.0) { continue }
let dx = wl_px - x0
let dz = wl_pz - z0
if Math.sqrt(dx * dx + dz * dz) < s.keep_away or wl_range_clashes(sp, wl_px, wl_pz) { continue }
if not wildlife_find_spot(wildlife_st, s.habitat, x0, z0, 120.0, 700.0) { continue }
let dx = wildlife_st.wl_px - x0
let dz = wildlife_st.wl_pz - z0
if Math.sqrt(dx * dx + dz * dz) < s.keep_away or wl_range_clashes(wildlife_st, sp, wildlife_st.wl_px, wildlife_st.wl_pz) { continue }
let r = new WildRange
r.sp = sp
r.x = wl_px
r.z = wl_pz
r.x = wildlife_st.wl_px
r.z = wildlife_st.wl_pz
r.r = s.range
r.sx = wl_px
r.sz = wl_pz
r.sx = wildlife_st.wl_px
r.sz = wildlife_st.wl_pz
wl_pick_winter(r)
push(wildlife_ranges(), r)
push(wildlife_ranges(wildlife_st), r)
return true
}
return false
}
# every species' ranges about (x0, z0), then the game told of each (WildlifeWorld.placed)
export function wildlife_ranges_setup(x0: float, z0: float) -> void {
wildlife_seed(613)
wl_ranges = new []WildRange
for sp in 0 .. wildlife_species_count() {
for k in 0 .. WildlifeWorld.ranges(sp) { if not wl_range_try(sp, x0, z0) { break } }
export function wildlife_ranges_setup(wildlife_st: mut WildlifeState, x0: float, z0: float) -> void {
wildlife_seed(wildlife_st, 613)
wildlife_st.wl_ranges = new []WildRange
for sp in 0 .. wildlife_species_count(wildlife_st) {
for k in 0 .. WildlifeWorld.ranges(sp) { if not wl_range_try(wildlife_st, sp, x0, z0) { break } }
}
wl_found_apply()
let rs = wildlife_ranges()
wl_found_apply(wildlife_st)
let rs = wildlife_ranges(wildlife_st)
for i in 0 .. len(rs) { WildlifeWorld.placed(rs[i], i) }
}
@ -85,13 +83,13 @@ function wl_pick_winter(r: WildRange) -> void {
}
# a player stood at (x, z): any range they are inside is found
export function wildlife_ranges_visit(x: float, z: float) -> void {
let rs = wildlife_ranges()
export function wildlife_ranges_visit(wildlife_st: mut WildlifeState, x: float, z: float) -> void {
let rs = wildlife_ranges(wildlife_st)
for i in 0 .. len(rs) { if not rs[i].found and wildlife_range_dist(rs[i], x, z) < rs[i].r { rs[i].found = true } }
}
function wl_found_apply() -> void {
if wl_found == null { return }
let rs = wildlife_ranges()
for i in 0 .. len(rs) { if i < len(wl_found) { rs[i].found = wl_found[i] != 0 } }
function wl_found_apply(wildlife_st: mut WildlifeState) -> void {
if wildlife_st.wl_found == null { return }
let rs = wildlife_ranges(wildlife_st)
for i in 0 .. len(rs) { if i < len(wildlife_st.wl_found) { rs[i].found = wildlife_st.wl_found[i] != 0 } }
}