@netforge/engine 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/GAME-DESIGN.md +195 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +30 -0
  4. package/README.md +147 -2
  5. package/dist/api/appearance.d.ts +37 -0
  6. package/dist/api/appearance.js +41 -0
  7. package/dist/api/cards.d.ts +105 -0
  8. package/dist/api/cards.js +133 -0
  9. package/dist/api/collector.d.ts +114 -0
  10. package/dist/api/collector.js +204 -0
  11. package/dist/api/dungeon.d.ts +58 -0
  12. package/dist/api/dungeon.js +216 -0
  13. package/dist/api/harness.d.ts +149 -0
  14. package/dist/api/harness.js +549 -0
  15. package/dist/api/idle.d.ts +71 -0
  16. package/dist/api/idle.js +104 -0
  17. package/dist/api/race-harness.d.ts +3 -0
  18. package/dist/api/race-harness.js +148 -0
  19. package/dist/api/registry.d.ts +241 -0
  20. package/dist/api/registry.js +394 -0
  21. package/dist/api/scheduler.d.ts +56 -0
  22. package/dist/api/scheduler.js +160 -0
  23. package/dist/api/schemas.d.ts +958 -0
  24. package/dist/api/schemas.js +859 -0
  25. package/dist/api/tower.d.ts +127 -0
  26. package/dist/api/tower.js +183 -0
  27. package/dist/game/adapter.d.ts +69 -0
  28. package/dist/game/adapter.js +341 -0
  29. package/dist/game/arena-bot.d.ts +66 -0
  30. package/dist/game/arena-bot.js +188 -0
  31. package/dist/game/bot.d.ts +95 -0
  32. package/dist/game/bot.js +285 -0
  33. package/dist/game/compile.d.ts +97 -0
  34. package/dist/game/compile.js +476 -0
  35. package/dist/game/director.d.ts +42 -0
  36. package/dist/game/director.js +179 -0
  37. package/dist/game/earn-source.d.ts +122 -0
  38. package/dist/game/earn-source.js +386 -0
  39. package/dist/game/earn.d.ts +49 -0
  40. package/dist/game/earn.js +55 -0
  41. package/dist/game/index.d.ts +37 -0
  42. package/dist/game/index.js +25 -0
  43. package/dist/game/platformer.d.ts +156 -0
  44. package/dist/game/platformer.js +619 -0
  45. package/dist/game/profile.d.ts +97 -0
  46. package/dist/game/profile.js +140 -0
  47. package/dist/game/race.d.ts +177 -0
  48. package/dist/game/race.js +386 -0
  49. package/dist/game/racer.d.ts +98 -0
  50. package/dist/game/racer.js +379 -0
  51. package/dist/game/runner.d.ts +286 -0
  52. package/dist/game/runner.js +824 -0
  53. package/dist/game/threats.d.ts +23 -0
  54. package/dist/game/threats.js +49 -0
  55. package/dist/game/view.d.ts +47 -0
  56. package/dist/game/view.js +123 -0
  57. package/dist/index.d.ts +33 -0
  58. package/dist/index.js +24 -0
  59. package/dist/net/bits.d.ts +33 -0
  60. package/dist/net/bits.js +135 -0
  61. package/dist/net/client.d.ts +75 -0
  62. package/dist/net/client.js +151 -0
  63. package/dist/net/index.d.ts +23 -0
  64. package/dist/net/index.js +23 -0
  65. package/dist/net/input.d.ts +49 -0
  66. package/dist/net/input.js +112 -0
  67. package/dist/net/interpolation.d.ts +37 -0
  68. package/dist/net/interpolation.js +97 -0
  69. package/dist/net/netsim.d.ts +22 -0
  70. package/dist/net/netsim.js +52 -0
  71. package/dist/net/prediction.d.ts +31 -0
  72. package/dist/net/prediction.js +101 -0
  73. package/dist/net/profile-client.d.ts +75 -0
  74. package/dist/net/profile-client.js +173 -0
  75. package/dist/net/protocol.d.ts +208 -0
  76. package/dist/net/protocol.js +8 -0
  77. package/dist/net/room-client.d.ts +57 -0
  78. package/dist/net/room-client.js +144 -0
  79. package/dist/net/schema.d.ts +78 -0
  80. package/dist/net/schema.js +121 -0
  81. package/dist/net/sim-adapter.d.ts +134 -0
  82. package/dist/net/sim-adapter.js +22 -0
  83. package/dist/net/snapshot.d.ts +61 -0
  84. package/dist/net/snapshot.js +301 -0
  85. package/dist/rules/adapter.d.ts +53 -0
  86. package/dist/rules/adapter.js +261 -0
  87. package/dist/rules/cards.d.ts +115 -0
  88. package/dist/rules/cards.js +547 -0
  89. package/dist/rules/collector.d.ts +161 -0
  90. package/dist/rules/collector.js +732 -0
  91. package/dist/rules/genres.d.ts +13 -0
  92. package/dist/rules/genres.js +38 -0
  93. package/dist/rules/harness.d.ts +16 -0
  94. package/dist/rules/harness.js +127 -0
  95. package/dist/rules/idle.d.ts +115 -0
  96. package/dist/rules/idle.js +370 -0
  97. package/dist/rules/index.d.ts +16 -0
  98. package/dist/rules/index.js +14 -0
  99. package/dist/rules/kit.d.ts +171 -0
  100. package/dist/rules/kit.js +88 -0
  101. package/dist/rules/tower.d.ts +214 -0
  102. package/dist/rules/tower.js +655 -0
  103. package/dist/runtime/arena.d.ts +86 -0
  104. package/dist/runtime/arena.js +269 -0
  105. package/dist/runtime/assets.d.ts +26 -0
  106. package/dist/runtime/assets.js +35 -0
  107. package/dist/runtime/camera.d.ts +113 -0
  108. package/dist/runtime/camera.js +247 -0
  109. package/dist/runtime/crowd.d.ts +18 -0
  110. package/dist/runtime/crowd.js +62 -0
  111. package/dist/runtime/feel/audio.d.ts +150 -0
  112. package/dist/runtime/feel/audio.js +327 -0
  113. package/dist/runtime/feel/clock.d.ts +52 -0
  114. package/dist/runtime/feel/clock.js +80 -0
  115. package/dist/runtime/feel/flash.d.ts +28 -0
  116. package/dist/runtime/feel/flash.js +60 -0
  117. package/dist/runtime/feel/index.d.ts +27 -0
  118. package/dist/runtime/feel/index.js +16 -0
  119. package/dist/runtime/feel/kit.d.ts +159 -0
  120. package/dist/runtime/feel/kit.js +226 -0
  121. package/dist/runtime/feel/knockback.d.ts +41 -0
  122. package/dist/runtime/feel/knockback.js +70 -0
  123. package/dist/runtime/feel/noise.d.ts +6 -0
  124. package/dist/runtime/feel/noise.js +30 -0
  125. package/dist/runtime/feel/numbers.d.ts +91 -0
  126. package/dist/runtime/feel/numbers.js +172 -0
  127. package/dist/runtime/feel/rumble.d.ts +40 -0
  128. package/dist/runtime/feel/rumble.js +58 -0
  129. package/dist/runtime/feel/sound.d.ts +96 -0
  130. package/dist/runtime/feel/sound.js +176 -0
  131. package/dist/runtime/feel/spring.d.ts +42 -0
  132. package/dist/runtime/feel/spring.js +95 -0
  133. package/dist/runtime/feel/trauma.d.ts +48 -0
  134. package/dist/runtime/feel/trauma.js +76 -0
  135. package/dist/runtime/feel/tween.d.ts +66 -0
  136. package/dist/runtime/feel/tween.js +180 -0
  137. package/dist/runtime/feel/types.d.ts +30 -0
  138. package/dist/runtime/feel/types.js +5 -0
  139. package/dist/runtime/index.d.ts +28 -0
  140. package/dist/runtime/index.js +26 -0
  141. package/dist/runtime/input.d.ts +38 -0
  142. package/dist/runtime/input.js +159 -0
  143. package/dist/runtime/interpolate.d.ts +6 -0
  144. package/dist/runtime/interpolate.js +13 -0
  145. package/dist/runtime/render/animation.d.ts +63 -0
  146. package/dist/runtime/render/animation.js +128 -0
  147. package/dist/runtime/render/atmosphere.d.ts +32 -0
  148. package/dist/runtime/render/atmosphere.js +59 -0
  149. package/dist/runtime/render/crowd-motion.d.ts +68 -0
  150. package/dist/runtime/render/crowd-motion.js +163 -0
  151. package/dist/runtime/render/decals.d.ts +64 -0
  152. package/dist/runtime/render/decals.js +222 -0
  153. package/dist/runtime/render/highlight.d.ts +29 -0
  154. package/dist/runtime/render/highlight.js +110 -0
  155. package/dist/runtime/render/index.d.ts +35 -0
  156. package/dist/runtime/render/index.js +22 -0
  157. package/dist/runtime/render/lighting.d.ts +50 -0
  158. package/dist/runtime/render/lighting.js +142 -0
  159. package/dist/runtime/render/particles.d.ts +117 -0
  160. package/dist/runtime/render/particles.js +289 -0
  161. package/dist/runtime/render/post.d.ts +92 -0
  162. package/dist/runtime/render/post.js +191 -0
  163. package/dist/runtime/render/presets.d.ts +57 -0
  164. package/dist/runtime/render/presets.js +116 -0
  165. package/dist/runtime/render/quality.d.ts +113 -0
  166. package/dist/runtime/render/quality.js +180 -0
  167. package/dist/runtime/render/rig.d.ts +29 -0
  168. package/dist/runtime/render/rig.js +107 -0
  169. package/dist/runtime/render/sprite.d.ts +34 -0
  170. package/dist/runtime/render/sprite.js +58 -0
  171. package/dist/runtime/render/stack.d.ts +74 -0
  172. package/dist/runtime/render/stack.js +132 -0
  173. package/dist/runtime/render/vat.d.ts +78 -0
  174. package/dist/runtime/render/vat.js +219 -0
  175. package/dist/runtime/renderer.d.ts +19 -0
  176. package/dist/runtime/renderer.js +18 -0
  177. package/dist/runtime/stats.d.ts +11 -0
  178. package/dist/runtime/stats.js +29 -0
  179. package/dist/runtime/styles/handdrawn/ground.d.ts +11 -0
  180. package/dist/runtime/styles/handdrawn/ground.js +282 -0
  181. package/dist/runtime/styles/handdrawn/index.d.ts +4 -0
  182. package/dist/runtime/styles/handdrawn/index.js +94 -0
  183. package/dist/runtime/styles/handdrawn/ink.d.ts +31 -0
  184. package/dist/runtime/styles/handdrawn/ink.js +68 -0
  185. package/dist/runtime/styles/handdrawn/looks.d.ts +18 -0
  186. package/dist/runtime/styles/handdrawn/looks.js +42 -0
  187. package/dist/runtime/styles/handdrawn/paint.d.ts +59 -0
  188. package/dist/runtime/styles/handdrawn/paint.js +129 -0
  189. package/dist/runtime/styles/handdrawn/palette.d.ts +49 -0
  190. package/dist/runtime/styles/handdrawn/palette.js +70 -0
  191. package/dist/runtime/styles/handdrawn/textures.d.ts +27 -0
  192. package/dist/runtime/styles/handdrawn/textures.js +150 -0
  193. package/dist/runtime/styles/handdrawn/vfx.d.ts +14 -0
  194. package/dist/runtime/styles/handdrawn/vfx.js +73 -0
  195. package/dist/runtime/styles/index.d.ts +9 -0
  196. package/dist/runtime/styles/index.js +32 -0
  197. package/dist/runtime/styles/kit.d.ts +193 -0
  198. package/dist/runtime/styles/kit.js +1 -0
  199. package/dist/runtime/styles/pixel/index.d.ts +46 -0
  200. package/dist/runtime/styles/pixel/index.js +167 -0
  201. package/dist/runtime/styles/ps1/index.d.ts +29 -0
  202. package/dist/runtime/styles/ps1/index.js +41 -0
  203. package/dist/runtime/styles/ps1/lights.d.ts +47 -0
  204. package/dist/runtime/styles/ps1/lights.js +146 -0
  205. package/dist/runtime/styles/ps1/materials.d.ts +62 -0
  206. package/dist/runtime/styles/ps1/materials.js +285 -0
  207. package/dist/runtime/styles/ps1/pipeline.d.ts +52 -0
  208. package/dist/runtime/styles/ps1/pipeline.js +111 -0
  209. package/dist/runtime/styles/ps1/surfaces.d.ts +44 -0
  210. package/dist/runtime/styles/ps1/surfaces.js +228 -0
  211. package/dist/runtime/styles/toon/index.d.ts +5 -0
  212. package/dist/runtime/styles/toon/index.js +178 -0
  213. package/dist/runtime/styles/toon/ink.d.ts +39 -0
  214. package/dist/runtime/styles/toon/ink.js +73 -0
  215. package/dist/runtime/styles/toon/look.d.ts +10 -0
  216. package/dist/runtime/styles/toon/look.js +112 -0
  217. package/dist/runtime/styles/toon/material.d.ts +74 -0
  218. package/dist/runtime/styles/toon/material.js +208 -0
  219. package/dist/runtime/styles/toon/normals.d.ts +26 -0
  220. package/dist/runtime/styles/toon/normals.js +127 -0
  221. package/dist/runtime/styles/toon/shadows.d.ts +24 -0
  222. package/dist/runtime/styles/toon/shadows.js +42 -0
  223. package/dist/runtime/styles/toon/vfx.d.ts +15 -0
  224. package/dist/runtime/styles/toon/vfx.js +47 -0
  225. package/dist/runtime/styles/view.d.ts +35 -0
  226. package/dist/runtime/styles/view.js +34 -0
  227. package/dist/runtime/styles/voxel/core.d.ts +114 -0
  228. package/dist/runtime/styles/voxel/core.js +577 -0
  229. package/dist/runtime/styles/voxel/geometry.d.ts +27 -0
  230. package/dist/runtime/styles/voxel/geometry.js +40 -0
  231. package/dist/runtime/styles/voxel/index.d.ts +21 -0
  232. package/dist/runtime/styles/voxel/index.js +23 -0
  233. package/dist/runtime/styles/voxel/kit.d.ts +6 -0
  234. package/dist/runtime/styles/voxel/kit.js +11 -0
  235. package/dist/runtime/styles/voxel/look.d.ts +10 -0
  236. package/dist/runtime/styles/voxel/look.js +16 -0
  237. package/dist/runtime/styles/voxel/props.d.ts +9 -0
  238. package/dist/runtime/styles/voxel/props.js +52 -0
  239. package/dist/runtime/styles/voxel/shapes.d.ts +41 -0
  240. package/dist/runtime/styles/voxel/shapes.js +83 -0
  241. package/dist/runtime/styles/voxel/world.d.ts +49 -0
  242. package/dist/runtime/styles/voxel/world.js +422 -0
  243. package/llms.txt +183 -0
  244. package/package.json +82 -3
@@ -0,0 +1,156 @@
1
+ /**
2
+ * The platformer template's machinery: compile a manifest's levels into the
3
+ * engine-sim platform sim, drive it with the race runner (race.ts), seat
4
+ * bots that run the course, a route planner that proves every level can be
5
+ * finished (the gate's softlock check), and the netcode SimAdapter.
6
+ */
7
+ import { capturePlatformPlayer } from "@netforge/engine-sim";
8
+ import type { InputCommand, PlatformLevel, PlatformPlayer, PlatformTuning, PlatformWorld, PlatStat } from "@netforge/engine-sim";
9
+ import type { GameManifest } from "../api/registry.js";
10
+ import type { BitReader, BitWriter } from "../net/bits.js";
11
+ import type { EntitySchema, EntityState } from "../net/schema.js";
12
+ import type { SimAdapter } from "../net/sim-adapter.js";
13
+ import { RaceRunner } from "./race.js";
14
+ import type { RaceCore, RaceRunnerOptions, RaceSimEvent } from "./race.js";
15
+ /** Platformer defaults: a 3 minute limit, 60 Hz, three seat bots. */
16
+ export declare const PLATFORMER_DEFAULTS: {
17
+ readonly roundSeconds: 180;
18
+ readonly tickRate: 60;
19
+ readonly bots: 3;
20
+ };
21
+ export interface CompiledPlatformer {
22
+ readonly levels: readonly PlatformLevel[];
23
+ /** Level names for the HUD (declared or "Level n"). */
24
+ readonly names: readonly string[];
25
+ readonly tuning: Partial<PlatformTuning>;
26
+ /** Per PLAT_STATS index: the step of the declared upgrade on that stat. */
27
+ readonly statSteps: readonly number[];
28
+ /** Per declared upgrade (declaration order): its platform stat. */
29
+ readonly upgradeStat: readonly PlatStat[];
30
+ }
31
+ /** Compile the platformer parts of a manifest. Issues are agent-readable. */
32
+ export declare function compilePlatformer(m: GameManifest, tickRate: number, issues: string[]): CompiledPlatformer;
33
+ /** Per-bot memory for the course runner. */
34
+ export interface PlatformBotMemory {
35
+ bestX: number;
36
+ since: number;
37
+ holdJump: number;
38
+ /** The planned run this bot follows, from the tick it started. */
39
+ tape?: readonly InputCommand[] | null;
40
+ tapeAt?: number;
41
+ }
42
+ /**
43
+ * What a course-running bot does this tick: run toward the flag, jump at
44
+ * walls, gaps and hazards, wait for a moving platform, hold Jump for a full
45
+ * jump, dash across a gap it is falling into. Deterministic.
46
+ */
47
+ export declare function platformBotInput(w: PlatformWorld, p: PlatformPlayer, mem: PlatformBotMemory, clock: number, skill: number): InputCommand;
48
+ export interface PlanResult {
49
+ readonly found: boolean;
50
+ /** Seconds the route takes. */
51
+ readonly seconds: number;
52
+ /** Furthest x reached. */
53
+ readonly bestX: number;
54
+ readonly expanded: number;
55
+ /** One input per tick from the start signal. */
56
+ readonly tape: readonly InputCommand[];
57
+ }
58
+ /**
59
+ * Search for a run from the start to the flag (the gate's softlock check:
60
+ * every level must be finishable). Best-first over short macro moves (run,
61
+ * jump of three heights, dash, wait) on a one-player copy of the sim, keyed
62
+ * by position cells so it never re-explores. Moving platforms run on the
63
+ * real clock from `startTick`.
64
+ */
65
+ export declare function planCourse(level: PlatformLevel, opts: {
66
+ tickRate: number;
67
+ tuning?: Partial<PlatformTuning>;
68
+ statSteps?: readonly number[];
69
+ startTick?: number;
70
+ budget?: number;
71
+ from?: ReturnType<typeof capturePlatformPlayer>;
72
+ }): PlanResult;
73
+ /** True when routeFor found no way from this course's start to its flag. */
74
+ export declare function unroutable(level: PlatformLevel): boolean;
75
+ /**
76
+ * A planned run from a climber's exact state (cached), or null when the
77
+ * planner found none. Without `from`, from the start at `startTick`.
78
+ */
79
+ export declare function routeFor(level: PlatformLevel, tickRate: number, tuning: Partial<PlatformTuning>, startTick: number, from?: ReturnType<typeof capturePlatformPlayer>): readonly InputCommand[] | null;
80
+ /** Seconds a bot of this skill waits after the start signal before running its route (quarter seconds). */
81
+ export declare function botDelaySeconds(id: number, skill: number): number;
82
+ /** The platform sim as the race runner drives it. */
83
+ export declare class PlatformCore implements RaceCore {
84
+ readonly compiled: CompiledPlatformer;
85
+ readonly tickRate: number;
86
+ readonly world: PlatformWorld;
87
+ private readonly memory;
88
+ /** World tick of this round's start signal (-1 while frozen). */
89
+ private startTick;
90
+ /** Players present at the start signal: they may run a planned route. */
91
+ private readonly starters;
92
+ constructor(compiled: CompiledPlatformer, tickRate: number);
93
+ ids(): number[];
94
+ add(id: number, bot: boolean, frozen: boolean): void;
95
+ remove(id: number): void;
96
+ reset(course: number, frozen: boolean): void;
97
+ setFrozen(frozen: boolean): void;
98
+ finished(id: number): boolean;
99
+ progress(id: number): number;
100
+ position(id: number): readonly [number, number, number];
101
+ step(inputs: ReadonlyMap<number, InputCommand>): RaceSimEvent[];
102
+ botInput(id: number, clock: number, skill: number): InputCommand;
103
+ grant(id: number, upgrade: number): boolean;
104
+ setCosmetic(id: number, cosmetic: number): void;
105
+ }
106
+ /** Field indices of the platformer wire schema. */
107
+ export declare const PF: {
108
+ readonly x: 0;
109
+ readonly y: 1;
110
+ readonly vx: 2;
111
+ readonly vy: 3;
112
+ readonly flags: 4;
113
+ readonly timers: 5;
114
+ readonly timers2: 6;
115
+ readonly cp: 7;
116
+ readonly coinsLo: 8;
117
+ readonly coinsHi: 9;
118
+ readonly finishTick: 10;
119
+ readonly stats: 11;
120
+ readonly cosmetic: 12;
121
+ readonly clock: 13;
122
+ };
123
+ export declare const platformSchema: EntitySchema;
124
+ /** The engine InputCommand on the wire (moves int8, yaw u16, buttons u16), shared by the race templates. */
125
+ export declare const raceInputCodec: {
126
+ idle: InputCommand;
127
+ write(w: BitWriter, i: InputCommand): void;
128
+ read(r: BitReader): InputCommand;
129
+ };
130
+ export interface PlatformRoomWorld {
131
+ readonly role: "server" | "client";
132
+ readonly core: PlatformCore;
133
+ readonly runner: RaceRunner | null;
134
+ }
135
+ export interface PlatformAdapterOptions {
136
+ readonly name: string;
137
+ readonly version: string;
138
+ readonly manifest: GameManifest;
139
+ readonly compiled: CompiledPlatformer;
140
+ readonly tickRate: number;
141
+ readonly bots: number;
142
+ readonly roundSeconds: number | null;
143
+ readonly runner?: RaceRunnerOptions;
144
+ }
145
+ /** The platformer's SimAdapter: the room runs the race; a client predicts only its own runner. */
146
+ export declare function platformAdapter(o: PlatformAdapterOptions): SimAdapter<PlatformRoomWorld, InputCommand>;
147
+ /** Throw the collected compile issues, agent-readable. */
148
+ export declare function assertNoIssues(issues: readonly string[]): void;
149
+ /**
150
+ * A playing autopilot for a client (measurement, previews, load tests): from
151
+ * the newest predicted state of our own climber it plans a route to the flag
152
+ * (cached by state), plays it back tick for tick on the course clock, and
153
+ * replans after a fall, a new course or the end of the tape. Falls back to
154
+ * the course bot's reflexes while no route is known.
155
+ */
156
+ export declare function platformAutopilot(compiled: CompiledPlatformer, tickRate: number): (self: EntityState | undefined, course: number, tick: number) => InputCommand;