break_eternity and eternal_notations. cmd line option for time

This commit is contained in:
azykov@mail.ru
2026-02-13 15:39:26 +03:00
parent 03d4948f64
commit a89f9b8141
12 changed files with 165 additions and 26 deletions
+5 -1
View File
@@ -12,7 +12,11 @@
"license": "ISC",
"type": "commonjs",
"dependencies": {
"@formatjs/intl-durationformat": "^0.10.1",
"@idle-economy/engine": "*",
"@formatjs/intl-durationformat": "^0.10.1"
"command-line-args": "^6.0.1"
},
"devDependencies": {
"@types/command-line-args": "^5.2.3"
}
}
+4 -2
View File
@@ -6,6 +6,7 @@ const durationFormat = new DurationFormat("en", { style: "short" });
export type SimulationStats = {
actions: Action[],
finalTime: number;
finalSnapshot: GameSnapshot,
}
@@ -50,6 +51,7 @@ export class Simulator {
time += deltaTime;
}
stats.finalTime = time;
stats.finalSnapshot = this.makeGameSnapshot();
this.log(time, "done");
@@ -82,8 +84,8 @@ export class Simulator {
lastTime = action.time;
maxDeltaTime = Math.max(maxDeltaTime, deltaTime);
}
this.log(0, `max action wait fime is ${maxDeltaTime}`)
this.log(0, `final data:: ${JSON.stringify(stats.finalSnapshot, undefined, 2)}`);
this.log(stats.finalTime, `max action wait fime is ${maxDeltaTime}`)
this.log(stats.finalTime, `final data: ${JSON.stringify(stats.finalSnapshot, undefined, 2)}`);
}
private logResources(time: number, resources: ResourceSet): void {
+6 -1
View File
@@ -1,16 +1,21 @@
import { makeGame } from '@idle-economy/engine';
import { Simulator } from './Simulator'
import { Player } from './player/Player';
import commandLineArgs from 'command-line-args'
process.on('SIGTERM', () => {
// Clean up resources and exit
process.exit(0);
});
const optionDefinitions: commandLineArgs.OptionDefinition[] = [
{ name: 'time', alias: 't', type: Number, defaultValue: 60 },
];
const options = commandLineArgs(optionDefinitions);
const game = makeGame();
const player = new Player(game);
const simulator = new Simulator(player);
simulator.simulate(3600);
simulator.simulate(options.time);