@korial29/tiny-fps 0.194.0 → 0.195.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.
- package/dist/index.js +44 -44
- package/dist/local.js +1 -1
- package/dist/server.js +682 -335
- package/dist/types/shared/bot.d.ts +9 -6
- package/dist/types/shared/nav.d.ts +55 -22
- package/dist/types/shared/room.d.ts +4 -0
- package/package.json +2 -1
|
@@ -69,13 +69,13 @@ export declare class Bot {
|
|
|
69
69
|
readonly id: number;
|
|
70
70
|
/** The route it prefers, an index of nav.ts's ROUTES. */
|
|
71
71
|
private prefer;
|
|
72
|
-
|
|
73
|
-
private
|
|
72
|
+
/** Its way: the points it goes through, walking or on a leg; the last is its goal or as near as it gets. */
|
|
73
|
+
private steps;
|
|
74
74
|
/** The goal of the way, and the tick it was planned. */
|
|
75
75
|
private goal;
|
|
76
76
|
private planned;
|
|
77
|
-
/**
|
|
78
|
-
private
|
|
77
|
+
/** The step it is on; steps.length once there. */
|
|
78
|
+
private step;
|
|
79
79
|
private flight;
|
|
80
80
|
/** The best distance to the point it walks to, and the tick it was last bettered. */
|
|
81
81
|
private best;
|
|
@@ -138,8 +138,6 @@ export declare class Bot {
|
|
|
138
138
|
/** Where it wants to be. */
|
|
139
139
|
private goalOf;
|
|
140
140
|
private plan;
|
|
141
|
-
/** The point it walks straight to now: the entry, a walk's end, or the goal past the last edge. */
|
|
142
|
-
private target;
|
|
143
141
|
/**
|
|
144
142
|
* The keys and yaw of the move, whether the bot may look away from it to shoot, and whether the
|
|
145
143
|
* yaw must be kept to the letter (a leg of a route, as the tests fly it).
|
|
@@ -165,6 +163,11 @@ export declare class Bot {
|
|
|
165
163
|
private unstick;
|
|
166
164
|
/** One step of a leg of a route, the way test/routes.ts flies it. */
|
|
167
165
|
private fly;
|
|
166
|
+
/**
|
|
167
|
+
* FORWARD or BACK in the air to come down on (x, y, z) facing it: will the flight carry it past
|
|
168
|
+
* the point, or short of it, by the time it is down at its height? 0 when it will land there.
|
|
169
|
+
*/
|
|
170
|
+
private alight;
|
|
168
171
|
/** Whether the edge after this one is a jump that wants the run-up of this one. */
|
|
169
172
|
private leapNext;
|
|
170
173
|
/** A leg is over: on to the next on its roof, else a new way from where the bot came down. */
|
|
@@ -1,42 +1,75 @@
|
|
|
1
1
|
import type { Leg } from './routes';
|
|
2
2
|
import type { World } from './world';
|
|
3
3
|
export type Vec3 = [number, number, number];
|
|
4
|
-
|
|
4
|
+
type Rect = [x0: number, z0: number, x1: number, z1: number];
|
|
5
|
+
/** A rectangle of floor at the height `y`, or on the relief's ground when `r`. */
|
|
6
|
+
export interface Poly {
|
|
7
|
+
q: Rect;
|
|
8
|
+
y: number;
|
|
9
|
+
r?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** How a body goes through a portal: walks either way, drops down it, or jumps up onto a box. */
|
|
12
|
+
export declare const PASS: {
|
|
13
|
+
readonly WALK: 0;
|
|
14
|
+
readonly DROP: 1;
|
|
15
|
+
readonly HOP: 2;
|
|
16
|
+
};
|
|
17
|
+
/** A way out of a rectangle: through a portal (from `a` to `b` on the line between the two), or a link of legs. */
|
|
5
18
|
export interface Edge {
|
|
6
19
|
to: number;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
20
|
+
a?: [number, number];
|
|
21
|
+
b?: [number, number];
|
|
22
|
+
pass?: number;
|
|
23
|
+
/** A link: where its first leg starts, where its last ends, its legs and the route it is a leg of (-1 none). */
|
|
24
|
+
from?: Vec3;
|
|
25
|
+
end?: Vec3;
|
|
26
|
+
legs?: Leg[];
|
|
27
|
+
route?: number;
|
|
28
|
+
/** Seconds, about, past the walk to it: a link's own. */
|
|
11
29
|
cost: number;
|
|
30
|
+
/** How often a bot came down off this link: each makes it dearer for the room's life. */
|
|
31
|
+
fails?: number;
|
|
32
|
+
/** The first link of a crossing (the moon's): AREA more for a bot that prefers another route. */
|
|
33
|
+
toll?: boolean;
|
|
12
34
|
}
|
|
13
35
|
export interface Nav {
|
|
14
|
-
|
|
15
|
-
/** The ways out of each node. */
|
|
36
|
+
polys: Poly[];
|
|
16
37
|
out: Edge[][];
|
|
17
|
-
/**
|
|
18
|
-
|
|
38
|
+
/** Cell key to the rectangles that touch the cell, PORTAL metres round included. */
|
|
39
|
+
grid: Map<number, number[]>;
|
|
40
|
+
/** The route each rectangle is a crossing of, an index of ROUTES; -1 for none. */
|
|
41
|
+
route: Int8Array;
|
|
42
|
+
}
|
|
43
|
+
/** A point a bot goes to: walking, or flying a leg there (`edge` the link of the leg). */
|
|
44
|
+
export interface Step {
|
|
45
|
+
to: Vec3;
|
|
46
|
+
leg?: Leg;
|
|
47
|
+
edge?: Edge;
|
|
19
48
|
}
|
|
20
49
|
/** The routes, fastest first: the Spine, Midtown, the Lowline. */
|
|
21
50
|
export declare const ROUTES: import("./routes").Route[];
|
|
51
|
+
/** Where a leg ends: a jump steers for its `to`, which is on the roof it lands on. */
|
|
52
|
+
export declare const end: (l: Leg) => Vec3;
|
|
53
|
+
/** The height of a rectangle's floor at (x, z). */
|
|
54
|
+
export declare const heightAt: (w: World, p: Poly, x: number, z: number) => number;
|
|
22
55
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* or the head from the height of a.
|
|
56
|
+
* The rectangle a body at `v` stands on, or the nearest one within NEAR metres, at most ABOVE over
|
|
57
|
+
* it and BELOW under it, as (index, the point of it to walk to); -1 when none.
|
|
26
58
|
*/
|
|
27
|
-
export declare const
|
|
59
|
+
export declare const locate: (nav: Nav, w: World, v: Vec3) => [number, Vec3];
|
|
28
60
|
/** Whether the bots' map of a world is built. */
|
|
29
61
|
export declare const navBuilt: (w: World) => boolean;
|
|
30
62
|
/** The bots' map of a world, built once per world. */
|
|
31
63
|
export declare const navOf: (w: World) => Nav;
|
|
32
|
-
/** A way across the map: walk straight to `entry`, follow the edges, then walk straight to the goal. */
|
|
33
|
-
export interface Way {
|
|
34
|
-
entry?: Vec3;
|
|
35
|
-
edges: Edge[];
|
|
36
|
-
}
|
|
37
64
|
/**
|
|
38
|
-
* The
|
|
39
|
-
*
|
|
40
|
-
|
|
65
|
+
* The corners of the shortest line from `s` to `t` through the portals, each [left, right] as one
|
|
66
|
+
* goes (the simple stupid funnel algorithm), `t` last.
|
|
67
|
+
*/
|
|
68
|
+
export declare const funnel: (s: number[], ports: [number[], number[]][], t: number[]) => number[][];
|
|
69
|
+
/**
|
|
70
|
+
* The points a bot goes through from `a` to `b`, the last `b` or, when no way gets there, the
|
|
71
|
+
* nearest point it can get to. The links of the routes other than `prefer` (an index of ROUTES)
|
|
72
|
+
* cost more, so bots that prefer different ones spread over the map. Off the mesh, `b` alone.
|
|
41
73
|
*/
|
|
42
|
-
export declare const path: (nav: Nav, w: World, a: Vec3, b: Vec3, prefer?: number) =>
|
|
74
|
+
export declare const path: (nav: Nav, w: World, a: Vec3, b: Vec3, prefer?: number) => Step[];
|
|
75
|
+
export {};
|
|
@@ -31,6 +31,8 @@ export declare class Room {
|
|
|
31
31
|
private mapName;
|
|
32
32
|
/** The map the host picked for the next match, when it is another one. */
|
|
33
33
|
private next;
|
|
34
|
+
/** The next map's world, built with the bots' mesh while the end screen runs rather than in the tick that starts the match. */
|
|
35
|
+
private ready;
|
|
34
36
|
/** Joins so far: each player's `since`. */
|
|
35
37
|
private joins;
|
|
36
38
|
/** Ids of bots let go this tick, not given again before the next: the person who takes a bot's place would be drawn where it stood. */
|
|
@@ -53,6 +55,8 @@ export declare class Room {
|
|
|
53
55
|
private host;
|
|
54
56
|
/** The map the host picked, from now on: a new world and a new match, the players in it. */
|
|
55
57
|
private load;
|
|
58
|
+
/** The next map's world and the bots' mesh of it, built ahead (Tranquility's mesh takes some 30 ms). */
|
|
59
|
+
private prepare;
|
|
56
60
|
/** Number of joined players, the bots left out: a room of bots alone is empty. */
|
|
57
61
|
get size(): number;
|
|
58
62
|
/** A peer opened. Nothing is sent until it joins. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.195.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"format": "npm run format:prettier && npm run format:eslint",
|
|
69
69
|
"test": "vitest run --coverage",
|
|
70
70
|
"test:ci": "vitest run --maxWorkers=100% --passWithNoTests",
|
|
71
|
+
"botmatch": "BOTMATCH=${BOTMATCH:-24} vitest run src/shared/botmatch.test.ts",
|
|
71
72
|
"test:durations": "vitest run --reporter=json --outputFile=node_modules/.cache/vitest-report.json && node scripts/durations.mjs node_modules/.cache/vitest-report.json",
|
|
72
73
|
"test:watch": "vitest --watch"
|
|
73
74
|
},
|