@hadoku/game-server 0.1.265 → 0.1.266

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.
@@ -1,13 +1,3 @@
1
- /**
2
- * Who an AI seat is: one of the platform's characters, named after it (the operator,
3
- * 2026-10-19: an AI plays as a character, by that character's own name). Generic to every
4
- * room — Magic's pods and tournaments draw their AIs here, and so does every plain room
5
- * (`plainRoomType`'s view, `seatPersonas`), so a bot looks and is named the same in every game.
6
- *
7
- * Drawn, never dealt in pool order: every room's first bot used to be the pool's first
8
- * character. Seeded by room and seat, so every reader of the same room — every page, every
9
- * restart — sees the same face, with nothing stored.
10
- */
11
1
  import type { AiPersona } from '@wolffm/platform-wire/seats';
12
2
  export type { AiPersona };
13
3
  type Face = string | null | undefined;
@@ -1,11 +1,15 @@
1
+ /**
2
+ * Who an AI seat is: one of the platform's characters, named after it (the operator,
3
+ * 2026-10-19: an AI plays as a character, by that character's own name). Generic to every
4
+ * room — Magic's pods and tournaments draw their AIs here, and so does every plain room
5
+ * (`plainRoomType`'s view, `seatPersonas`), so a bot looks and is named the same in every game.
6
+ *
7
+ * Drawn, never dealt in pool order: every room's first bot used to be the pool's first
8
+ * character. Seeded by room and seat, so every reader of the same room — every page, every
9
+ * restart — sees the same face, with nothing stored.
10
+ */
11
+ import { hashSeed } from '@wolffm/platform-wire/random';
1
12
  import { AVATAR_POOL } from '@wolffm/rooms-protocol';
2
- /** FNV-1a: a stable 32-bit number for a string, so a seeded pick is the same on every run. */
3
- function seedOf(text) {
4
- let h = 0x811c9dc5;
5
- for (let i = 0; i < text.length; i++)
6
- h = Math.imul(h ^ text.charCodeAt(i), 0x01000193);
7
- return h >>> 0;
8
- }
9
13
  /** `knight` → Knight. */
10
14
  export function personaOf(avatarId) {
11
15
  return { name: avatarId.charAt(0).toUpperCase() + avatarId.slice(1), avatarId };
@@ -31,14 +35,17 @@ export function drawAvatar(seed, ...tiers) {
31
35
  const min = Math.min(...least.map((a) => n.get(a) ?? 0));
32
36
  least = least.filter((a) => (n.get(a) ?? 0) === min);
33
37
  }
34
- return least[seedOf(seed) % least.length];
38
+ return least[hashSeed(seed) % least.length];
35
39
  }
36
- /** The pool in an order of `seed`'s own: the same seed, the same order (a seeded Fisher–Yates). */
40
+ /**
41
+ * The pool in an order of `seed`'s own: the same seed, the same order (a seeded Fisher–Yates).
42
+ * It steps xorshift32, not the platform's mulberry32: every room's bots wear the faces this order
43
+ * dealt them, and another generator would re-deal every existing room's faces.
44
+ */
37
45
  function poolOrder(seed) {
38
46
  const order = [...AVATAR_POOL];
39
- let state = seedOf(seed) || 1;
47
+ let state = hashSeed(seed) || 1;
40
48
  for (let i = order.length - 1; i > 0; i--) {
41
- // xorshift32: enough spread for a shuffle of a couple of dozen faces.
42
49
  state ^= state << 13;
43
50
  state ^= state >>> 17;
44
51
  state ^= state << 5;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-server",
3
- "version": "0.1.265",
4
- "gitHead": "8b28f20837041731519c303b5c9aff80deed9780",
3
+ "version": "0.1.266",
4
+ "gitHead": "33e217cc0042251707965b5aaac76997909d9fdf",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The server parts any hosted game shares, above the kernel: the app config and edge auth, the room core (identity, seats, sessions, membership, the room list, the generic room routes), match hosting (the host contract, local and remote JVMs, placement, the start queue, recordings, the in-process and relay runtimes), streams, erase, telemetry and usage. Knows no game; Magic plugs in from apps/server. MIT; imports only node built-ins, express, socket.io, @wolffm/* and the platform packages.",
@@ -16,9 +16,9 @@
16
16
  "play/remote/"
17
17
  ],
18
18
  "dependencies": {
19
- "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.265",
20
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.265",
21
- "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.298",
19
+ "@wolffm/host-wire": "npm:@hadoku/host-wire@0.1.266",
20
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.266",
21
+ "@wolffm/service-kernel": "npm:@hadoku/service-kernel@0.1.299",
22
22
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.4",
23
23
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.158",
24
24
  "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.158",