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.vehicles/fact_pool.ludic
Normal file
14
packages/ludic.vehicles/fact_pool.ludic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# ludic.vehicles/fact_pool.ludic - the facts' records made at the start (VEHICLEFACTS 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 VE_FACTS: int = 64
|
||||
|
||||
function ve_fpool_new() -> []VehicleFact {
|
||||
let l = new []VehicleFact
|
||||
for i in 0 .. VE_FACTS { push(l, new VehicleFact) }
|
||||
return l
|
||||
}
|
||||
function ve_ffree_new() -> []VehicleFact {
|
||||
let l = ve_fpool_new()
|
||||
List.clear(l)
|
||||
return l
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import "ludic.base"
|
|||
import "kinds.ludic"
|
||||
import "table.ludic"
|
||||
import "ports.ludic"
|
||||
import "fact_pool.ludic"
|
||||
import "state.ludic"
|
||||
import "places.ludic"
|
||||
import "call.ludic"
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ export state VehiclesState {
|
|||
ve_ly: float = 0.0
|
||||
ve_lz: float = 0.0
|
||||
ve_fact_q: Queue<VehicleFact> = ve_fact_q__new()
|
||||
ve_fpool: []VehicleFact = new []VehicleFact # every fact record made, reused once no drain holds it
|
||||
ve_ffree: []VehicleFact = new []VehicleFact
|
||||
ve_fpool: []VehicleFact = ve_fpool_new() # every fact record made, reused once no drain holds it
|
||||
ve_ffree: []VehicleFact = ve_ffree_new()
|
||||
ve_fnext: int = 0
|
||||
}
|
||||
function ve__dry(x: float, z: float) -> float { return -10000.0 }
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ program VehiclesTest {
|
|||
expect(vehicle_by_nid(vehicles_st, b.nid) == null)
|
||||
}
|
||||
|
||||
test "a fed fact a turn, drained each turn, makes a few records and then reuses them" (vehicles_st: mut VehiclesState, vehicles_test_st: mut VehiclesTestState) {
|
||||
test "a fed fact a turn, drained each turn, makes no record past the ones made at the start" (vehicles_st: mut VehiclesState, vehicles_test_st: mut VehiclesTestState) {
|
||||
fresh(vehicles_st, vehicles_test_st)
|
||||
vehicle_call_for(vehicles_st, 0, VEHICLE_HORSE, 0)
|
||||
let h = vehicle_find(vehicles_st, VEHICLE_HORSE)
|
||||
|
|
@ -386,6 +386,6 @@ program VehiclesTest {
|
|||
fed += count(facts(vehicles_st), VEHICLE_FED)
|
||||
}
|
||||
expect_eq(fed, 1000)
|
||||
expect(vehicle_fact_records(vehicles_st) <= 4)
|
||||
expect_eq(vehicle_fact_records(vehicles_st), 64)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue