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:
parent
5ffe50ed02
commit
19fcf60599
459 changed files with 17862 additions and 17603 deletions
|
|
@ -1,21 +1,21 @@
|
|||
# spawn.ludic - a valley filled: ranges set out, then each range to its target on its own habitat.
|
||||
# Each morning the ranges move with the season and every range under its target gets ONE back,
|
||||
# out of every player's sight: a valley recovers, it does not refill.
|
||||
export function wildlife_spawn(x0: float, z0: float) -> void {
|
||||
wildlife_ranges_setup(x0, z0)
|
||||
wildlife_seed(97)
|
||||
let rs = wildlife_ranges()
|
||||
for i in 0 .. len(rs) { wl_fill(i, WildlifeWorld.per_range(rs[i].sp)) }
|
||||
wildlife_ranges_migrate()
|
||||
export function wildlife_spawn(wildlife_st: mut WildlifeState, x0: float, z0: float) -> void {
|
||||
wildlife_ranges_setup(wildlife_st, x0, z0)
|
||||
wildlife_seed(wildlife_st, 97)
|
||||
let rs = wildlife_ranges(wildlife_st)
|
||||
for i in 0 .. len(rs) { wl_fill(wildlife_st, i, WildlifeWorld.per_range(rs[i].sp)) }
|
||||
wildlife_ranges_migrate(wildlife_st)
|
||||
}
|
||||
|
||||
# up to `want` more in range i; returns how many went in
|
||||
function wl_fill(i: int, want: int) -> int {
|
||||
let r = wildlife_range(i)
|
||||
function wl_fill(wildlife_st: mut WildlifeState, i: int, want: int) -> int {
|
||||
let r = wildlife_range(wildlife_st, i)
|
||||
var made = 0
|
||||
for k in 0 .. want {
|
||||
if not wildlife_find_spot(wl_sp(r.sp).habitat, r.x, r.z, 0.0, r.r) { continue }
|
||||
let a = wildlife_new(r.sp, wl_px, wl_pz, false)
|
||||
if not wildlife_find_spot(wildlife_st, wl_sp(wildlife_st, r.sp).habitat, r.x, r.z, 0.0, r.r) { continue }
|
||||
let a = wildlife_new(wildlife_st, r.sp, wildlife_st.wl_px, wildlife_st.wl_pz, false)
|
||||
if a != null {
|
||||
a.rg = i
|
||||
made += 1
|
||||
|
|
@ -25,22 +25,22 @@ function wl_fill(i: int, want: int) -> int {
|
|||
}
|
||||
|
||||
# each morning: the ranges slide with the season, and the valley gets back what it lost
|
||||
export function wildlife_morning() -> int {
|
||||
wildlife_ranges_migrate()
|
||||
return wildlife_repopulate()
|
||||
export function wildlife_morning(wildlife_st: mut WildlifeState) -> int {
|
||||
wildlife_ranges_migrate(wildlife_st)
|
||||
return wildlife_repopulate(wildlife_st)
|
||||
}
|
||||
|
||||
# one newcomer for each range under its target, never within 200 m of a player; how many came
|
||||
export function wildlife_repopulate() -> int {
|
||||
let rs = wildlife_ranges()
|
||||
export function wildlife_repopulate(wildlife_st: mut WildlifeState) -> int {
|
||||
let rs = wildlife_ranges(wildlife_st)
|
||||
var added = 0
|
||||
for i in 0 .. len(rs) {
|
||||
let want = WildlifeWorld.per_range(rs[i].sp)
|
||||
if want == 0 or wildlife_range_alive(i) >= want { continue }
|
||||
if want == 0 or wildlife_range_alive(wildlife_st, i) >= want { continue }
|
||||
for t in 0 .. 12 {
|
||||
if not wildlife_find_spot(wl_sp(rs[i].sp).habitat, rs[i].x, rs[i].z, 0.0, rs[i].r) { continue }
|
||||
if wl_near(wl_px, wl_pz) < 200.0 { continue }
|
||||
let a = wildlife_new(rs[i].sp, wl_px, wl_pz, false)
|
||||
if not wildlife_find_spot(wildlife_st, wl_sp(wildlife_st, rs[i].sp).habitat, rs[i].x, rs[i].z, 0.0, rs[i].r) { continue }
|
||||
if wl_near(wildlife_st, wildlife_st.wl_px, wildlife_st.wl_pz) < 200.0 { continue }
|
||||
let a = wildlife_new(wildlife_st, rs[i].sp, wildlife_st.wl_px, wildlife_st.wl_pz, false)
|
||||
if a != null {
|
||||
a.rg = i
|
||||
added += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue