fix: clear destroyed-NPC state; use true EV in trade scoring (review)
This commit is contained in:
+3
-1
@@ -70,7 +70,7 @@ export function planNpc(world, npc) {
|
||||
if (sellP <= buyP * 1.15) continue; // demand a margin over price noise
|
||||
const qty = Math.min(npc.capacity, Math.floor(npc.credits / buyP), Math.floor(origin.stock[good] * 0.5));
|
||||
if (qty < 1) continue;
|
||||
const profit = (sellP - buyP) * qty * survival;
|
||||
const profit = (sellP * survival - buyP) * qty; // EV: buy cost is sunk even if cargo is lost
|
||||
if (profit <= 0) continue;
|
||||
const days = Math.max(LOCAL_HOP_DAYS, route.days);
|
||||
const noise = 0.9 + 0.2 * rollFor(npc.seed, `${planId}:noise:${dest.id}:${good}`);
|
||||
@@ -111,6 +111,8 @@ export function onNpcArrive(world, { npcId, planId }) {
|
||||
if (plan.finalOutcome === 'destroyed') {
|
||||
npc.alive = false;
|
||||
npc.plan = null;
|
||||
npc.cargo = null;
|
||||
npc.state = 'destroyed';
|
||||
world.stats.npcDestroyed++;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user