fix(character, physics, vehicles, wildlife): fact records made at the start (64) with a free list of room for all, as ludic.npc's
A frame holding a new peak of facts made a record and grew the free list; now nothing is made until 64 are held at once. The two record-count tests hold the 64. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7f973f9a4f
commit
c8c230449e
14 changed files with 72 additions and 12 deletions
14
packages/ludic.wildlife/fact_pool.ludic
Normal file
14
packages/ludic.wildlife/fact_pool.ludic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# ludic.wildlife/fact_pool.ludic - the facts' records made at the start (WILDFACTS of them) with a free list
|
||||
# of room for all, so a frame holding a new peak of facts makes nothing until that many are held
|
||||
const WL_FACTS: int = 64
|
||||
|
||||
function wl_fpool_new() -> []WildFact {
|
||||
let l = new []WildFact
|
||||
for i in 0 .. WL_FACTS { push(l, new WildFact) }
|
||||
return l
|
||||
}
|
||||
function wl_ffree_new() -> []WildFact {
|
||||
let l = wl_fpool_new()
|
||||
List.clear(l)
|
||||
return l
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ module ludic_wildlife uses ludic_base
|
|||
numbers float
|
||||
import "ludic.base"
|
||||
import "species.ludic"
|
||||
import "fact_pool.ludic"
|
||||
import "animal.ludic"
|
||||
import "places.ludic"
|
||||
import "port.ludic"
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ export property WildSpecies {
|
|||
|
||||
export state WildlifeState {
|
||||
wl_facts: Queue<WildFact> = wl_facts__new()
|
||||
wl_fpool: []WildFact = new []WildFact # every fact record made, reused once no drain holds it
|
||||
wl_ffree: []WildFact = new []WildFact # of those, the ones free at the last look
|
||||
wl_fpool: []WildFact = wl_fpool_new() # every fact record made, reused once no drain holds it
|
||||
wl_ffree: []WildFact = wl_ffree_new() # of those, the ones free at the last look
|
||||
wl_fnext: []int = words(1) # the next of them to hand out
|
||||
wl_own: WildTable = null # a guest's own animals, put away whole while it draws the host's
|
||||
wl_px: float = 0.0
|
||||
|
|
|
|||
|
|
@ -84,13 +84,13 @@ program WildCrowdTest {
|
|||
expect(not wildlife_listed(wildlife_st, a))
|
||||
}
|
||||
|
||||
test "a fact a frame, drained each frame, makes a few records and then reuses them" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
test "a fact a frame, drained each frame, makes no record past the ones made at the start" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
let a = walker(wildlife_st, wildlife_tests_fake_st)
|
||||
for k in 1 .. 3001 {
|
||||
wildlife_moved(wildlife_st, a, 0.0, -3.0 * float(k), 0.0, -1.2)
|
||||
let fs = q_drain(wildlife_facts(wildlife_st))
|
||||
for i in 0 .. len(fs) { expect_eq(fs[i].what, WILD_PRINT) }
|
||||
}
|
||||
expect(wildlife_fact_records(wildlife_st) <= 4)
|
||||
expect_eq(wildlife_fact_records(wildlife_st), 64)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue