feat(arena): add deterministic headless RL environments
This commit is contained in:
@@ -334,6 +334,25 @@ export class AircraftController {
|
||||
return { ...this.current };
|
||||
}
|
||||
|
||||
/** Restore a trusted JSON snapshot for deterministic environment checkpointing. */
|
||||
restore(snapshot: AircraftControllerSnapshot): void {
|
||||
const numeric = Object.entries(snapshot)
|
||||
.filter(([, value]) => typeof value === "number")
|
||||
.every(([, value]) => Number.isFinite(value));
|
||||
const envelope = this.options.envelope;
|
||||
if (
|
||||
!numeric || (snapshot.mode !== "manual" && snapshot.mode !== "assisted") ||
|
||||
snapshot.lat < envelope.minLat || snapshot.lat > envelope.maxLat ||
|
||||
snapshot.lng < envelope.minLng || snapshot.lng > envelope.maxLng ||
|
||||
snapshot.altitudeM < envelope.minAltitudeM || snapshot.altitudeM > envelope.maxAltitudeM ||
|
||||
snapshot.speedMps < this.options.minimumSpeedMps ||
|
||||
snapshot.speedMps > this.options.maximumSpeedMps ||
|
||||
!Number.isSafeInteger(snapshot.elapsedSteps) || snapshot.elapsedSteps < 0
|
||||
) throw new RangeError("aircraft snapshot is incompatible or invalid");
|
||||
Object.assign(this.current, snapshot);
|
||||
this.accumulator = 0;
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.accumulator = 0;
|
||||
Object.assign(this.current, this.options.initialPosition, {
|
||||
|
||||
Reference in New Issue
Block a user