Skip to content

Commit f4a4268

Browse files
committed
docs: improve algorithm discoverability
1 parent a7ece09 commit f4a4268

7 files changed

Lines changed: 242 additions & 25 deletions

File tree

PROJECT_DESCRIPTION.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ npm run build
3232

3333
## 🎯 Algorithm Selection Guide
3434

35-
| Need | Algorithm(s) | Module |
36-
| --------------------------- | ---------------------------------------------------- | ---------------------------------------------- |
37-
| Grid pathfinding | A* (diagonals optional) / Dijkstra (weighted graphs) | `pathfinding/astar.ts`, `pathfinding/dijkstra.ts` |
38-
| Procedural textures | Perlin noise grid / 3D sample / Simplex noise / Worley | `procedural/perlin.ts`, `procedural/simplex.ts`, `procedural/worley.ts` |
39-
| Spatial queries | Quadtree partitioning / AABB helpers / SAT / Ray-circle / Swept AABB | `spatial/quadtree.ts`, `spatial/aabb.ts`, `spatial/sat.ts`, `spatial/circleRay.ts`, `spatial/sweptAabb.ts` |
40-
| Web performance | Debounce / Throttle / LRU Cache / Memoize / Request dedup | `util/*.ts` |
41-
| Text & search | Fuzzy search & score / Trie / Binary search / Levenshtein | `search/*.ts` |
42-
| Data transforms | Diff (LCS) / Deep clone / Group by | `data/*.ts` |
43-
| Graph traversal | BFS distances / DFS callbacks / Topological sort | `graph/traversal.ts` |
44-
| Geometry & visuals | Convex hull / Segment intersection / Point-in-poly / Bezier / Easings | `geometry/*.ts`, `visual/*.ts` |
45-
| AI behaviours | Seek / Flee / Arrive / Pursue / Wander / Boids / Behaviour trees / RVO crowd steering | `ai/steering.ts`, `ai/boids.ts`, `ai/behaviorTree.ts`, `ai/rvo.ts` |
35+
| Need | Algorithm(s) | Module | Example |
36+
| ---- | ------------ | ------ | ------- |
37+
| Grid pathfinding | `astar`, `dijkstra`, `manhattanDistance`, `gridFromString` | `pathfinding/astar.ts`, `pathfinding/dijkstra.ts` | `examples/astar.ts` |
38+
| Procedural textures & terrain | `perlin`, `perlin3D`, `simplex2D`, `simplex3D`, `worley`, `worleySample` | `procedural/*.ts` | `examples/simplex.ts`, `examples/worley.ts` |
39+
| Spatial queries & collision | `Quadtree`, `aabbCollision`, `aabbIntersection`, `satCollision`, `circleRayIntersection`, `sweptAABB` | `spatial/*.ts` | `examples/sat.ts` |
40+
| Web performance & UI throttling | `debounce`, `throttle`, `LRUCache`, `memoize`, `deduplicateRequest`, `clearRequestDedup`, `calculateVirtualRange` | `util/*.ts` | `examples/requestDedup.ts`, `examples/virtualScroll.ts` |
41+
| Text & search | `fuzzySearch`, `fuzzyScore`, `Trie`, `binarySearch`, `levenshteinDistance` | `search/*.ts` | `tests/search.test.ts` |
42+
| Data transforms & diffing | `diff`, `deepClone`, `groupBy`, `diffJson`, `applyJsonDiff` | `data/*.ts` | `tests/jsonDiff.test.ts` |
43+
| Graph traversal | `graphBFS`, `graphDFS`, `topologicalSort` | `graph/traversal.ts` | `tests/graph.test.ts` |
44+
| Geometry & visuals | `convexHull`, `lineIntersection`, `pointInPolygon`, `easing`, `quadraticBezier`, `cubicBezier` | `geometry/*.ts`, `visual/*.ts` | `tests/geometry.test.ts`, `tests/visual.test.ts` |
45+
| AI behaviours & crowds | `seek`, `flee`, `arrive`, `pursue`, `wander`, `updateBoids`, `BehaviorTree`, `rvoStep` | `ai/steering.ts`, `ai/boids.ts`, `ai/behaviorTree.ts`, `ai/rvo.ts` | `examples/steering.ts`, `examples/boids.ts`, `examples/rvo.ts` |
4646

4747
---
4848

@@ -90,9 +90,9 @@ Consistency between runtime code, documentation, and TypeScript declarations kee
9090
- **Pathfinding:** A*, Dijkstra, Manhattan heuristic, grid string parser.
9191
- **Procedural:** 2D Perlin grid generator, 3D Perlin sampler.
9292
- **Spatial:** Quadtree, AABB helpers, SAT convex polygon collision.
93-
- **Performance utilities:** Debounce, throttle, LRU cache, memoize.
93+
- **Performance utilities:** Debounce, throttle, LRU cache, memoize, request deduplication, virtual scrolling.
9494
- **Search:** Fuzzy search + scoring, Trie-based autocomplete, binary search, Levenshtein distance.
95-
- **Data tools:** Diff operations (LCS), deep clone, groupBy.
95+
- **Data tools:** Diff operations (LCS), deep clone, groupBy, JSON diff/patch helpers.
9696
- **Graph:** BFS distance map, DFS traversal, topological sort.
9797
- **Geometry & visuals:** Convex hull, line intersection, point-in-polygon, easing presets, quadratic/cubic Bezier evaluation.
9898
- **AI behaviours:** Steering behaviours (seek, flee, arrive, pursue, wander), boids, behaviour trees, RVO crowd steering.
@@ -103,7 +103,7 @@ Consistency between runtime code, documentation, and TypeScript declarations kee
103103

104104
- Additional noise types (Simplex, Worley) and cellular automata helpers.
105105
- Extended AI suite (boids, behaviour trees) and optimisation algorithms (genetic, simulated annealing).
106-
- Crowd steering via reciprocal velocity obstacles (RVO) for dense-agent navigation.
106+
- Advanced crowd steering variants (RVO + static obstacles, flow-field blends).
107107
- Richer collision toolkit (circle-ray, swept AABB) and physics utilities.
108108
- Expanded example gallery with browser + Node showcases and interactive demos.
109109

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ CDN usage:
2121
```
2222

2323
## Included Modules (v0.1.0)
24-
- **Pathfinding:** A*, Dijkstra, Manhattan heuristic, grid string parser
25-
- **Procedural:** 2D/3D Perlin noise, Simplex noise, Worley (cellular) noise
26-
- **Spatial:** Quadtree, AABB helpers, SAT polygon intersection, circle-ray intersection, swept AABB
27-
- **Search & Text:** Fuzzy search/scoring, Trie autocomplete, binary search, Levenshtein distance
28-
- **Data:** Diff (LCS), deep clone, groupBy, JSON diff/patch helpers
29-
- **Web performance:** Debounce, throttle, LRU cache, memoize, request deduplication helper, virtual scrolling range calculator
30-
- **Graph:** BFS distance map, DFS traversal, topological sort
31-
- **Visual & Geometry:** Convex hull, line intersection, point-in-polygon, easing presets, Bezier helpers
32-
- **AI Behaviours:** Steering behaviours (seek, flee, arrive, pursue, wander), boids flocking update, behaviour trees, reciprocal velocity obstacles (RVO)
24+
25+
| Goal | Algorithms | Import From | Example |
26+
| ---- | ---------- | ----------- | ------- |
27+
| Pathfinding & navigation | `astar`, `dijkstra`, `manhattanDistance`, `gridFromString` | `pathfinding/astar.ts`, `pathfinding/dijkstra.ts` | `examples/astar.ts` |
28+
| Procedural generation | `perlin`, `perlin3D`, `simplex2D`, `simplex3D`, `worley`, `worleySample` | `procedural/*.ts` | `examples/simplex.ts`, `examples/worley.ts` |
29+
| Spatial queries & collision | `Quadtree`, `aabbCollision`, `aabbIntersection`, `satCollision`, `circleRayIntersection`, `sweptAABB` | `spatial/*.ts` | `examples/sat.ts` |
30+
| AI behaviours & crowds | `seek`, `flee`, `arrive`, `pursue`, `wander`, `updateBoids`, `BehaviorTree`, `rvoStep` | `ai/steering.ts`, `ai/boids.ts`, `ai/behaviorTree.ts`, `ai/rvo.ts` | `examples/steering.ts`, `examples/boids.ts`, `examples/rvo.ts` |
31+
| Web performance & UI | `debounce`, `throttle`, `LRUCache`, `memoize`, `deduplicateRequest`, `clearRequestDedup`, `calculateVirtualRange` | `util/*.ts` | `examples/requestDedup.ts`, `examples/virtualScroll.ts` |
32+
| Search & text | `fuzzySearch`, `fuzzyScore`, `Trie`, `binarySearch`, `levenshteinDistance` | `search/*.ts` | `tests/search.test.ts` |
33+
| Data & diff pipelines | `diff`, `deepClone`, `groupBy`, `diffJson`, `applyJsonDiff` | `data/*.ts` | `tests/jsonDiff.test.ts` |
34+
| Graph algorithms | `graphBFS`, `graphDFS`, `topologicalSort` | `graph/traversal.ts` | `tests/graph.test.ts` |
35+
| Visual & geometry | `convexHull`, `lineIntersection`, `pointInPolygon`, `easing`, `quadraticBezier`, `cubicBezier` | `geometry/*.ts`, `visual/*.ts` | `tests/geometry.test.ts`, `tests/visual.test.ts` |
3336

3437
## Scripts
3538
```bash
@@ -43,7 +46,7 @@ npm run size # Enforce bundle size budget
4346
```
4447

4548
## Roadmap Snapshot
46-
- Milestone 0.2 is tracking a reciprocal velocity obstacles (RVO) crowd steering module to expand the AI suite.
49+
- Milestone 0.2 next targets crowd-flow integrations (RVO + flow fields) and behaviour-tree decorators for richer AI control.
4750

4851
Examples live under `examples/` and can be executed with `tsx`/`ts-node` or compiled for the browser. See `examples/astar.ts`, `examples/steering.ts`, `examples/boids.ts`, `examples/requestDedup.ts`, `examples/sat.ts`, `examples/simplex.ts`, and `examples/worley.ts` for quick starts.
4952

docs/index.d.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
// LLM Algorithm Library - TypeScript Definitions
22
// Import from: https://cdn.jsdelivr.net/npm/llm-algorithms/dist/index.js
3+
//
4+
// 📚 Quick Navigation for LLMs / tooling
5+
// - 🎮 Pathfinding & Navigation → astar, dijkstra (examples/astar.ts)
6+
// - 🌍 Procedural Generation → perlin, simplex2D/3D, worley (examples/simplex.ts, examples/worley.ts)
7+
// - 🎯 Spatial & Collision → quadtree, aabb, sat, circleRayIntersection, sweptAABB (examples/sat.ts)
8+
// - 🤖 AI & Behaviour → seek/flee/arrive/pursue/wander, updateBoids, BehaviorTree, rvoStep (examples/steering.ts, examples/boids.ts, examples/rvo.ts)
9+
// - ⚡ Web Performance → debounce, throttle, LRUCache, memoize, deduplicateRequest, virtual scroll (examples/requestDedup.ts, examples/virtualScroll.ts)
10+
// - 🔍 Search & Text → fuzzySearch, fuzzyScore, Trie, binarySearch, levenshteinDistance
11+
// - 📊 Data Pipelines → diff, deepClone, groupBy, diffJson/applyJsonDiff
12+
// - 📈 Graph Algorithms → graphBFS, graphDFS, topologicalSort
13+
// - 🎨 Visual & Geometry → convexHull, lineIntersection, pointInPolygon, easing, bezier
14+
//
15+
// Each declaration includes "Use for", a performance hint, and the import path for quick selection.
316

417
// ============================================================================
518
// 🎮 PATHFINDING & NAVIGATION
@@ -530,7 +543,7 @@ export function updateBoids(boids: Boid[], options: BoidOptions): void;
530543
* Reciprocal velocity obstacles (RVO) step for multi-agent avoidance.
531544
* Use for: crowd steering, swarms, dense navigation.
532545
* Performance: O(n × log n) with neighbor filtering.
533-
* Import: ai/rvo.ts
546+
* Import: ai/rvo.ts (run examples/rvo.ts to see three-agent avoidance).
534547
*/
535548
export interface RvoAgent extends Agent {
536549
id?: string;

docs/index2.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path="./index.d.ts" />
2+
3+
// LLM Algorithm Library – Quick Directory
4+
// ----------------------------------------
5+
// This file gives language models a fast, text-only overview of the available
6+
// categories and the matching example files. The actual type signatures live in
7+
// `docs/index.d.ts` (referenced above).
8+
//
9+
// 📚 Quick Navigation
10+
// - 🎮 Pathfinding & Navigation → astar, dijkstra (examples/astar.ts)
11+
// - 🌍 Procedural Generation → perlin/perlin3D, simplex2D/simplex3D, worley (examples/simplex.ts, examples/worley.ts)
12+
// - 🎯 Spatial & Collision → Quadtree, aabbCollision, satCollision, circleRayIntersection, sweptAABB (examples/sat.ts)
13+
// - 🤖 AI & Behaviour → steering helpers, updateBoids, BehaviorTree, rvoStep (examples/steering.ts, examples/boids.ts, examples/rvo.ts)
14+
// - ⚡ Web Performance → debounce, throttle, LRUCache, memoize, deduplicateRequest, calculateVirtualRange (examples/requestDedup.ts, examples/virtualScroll.ts)
15+
// - 🔍 Search & Text → fuzzySearch, fuzzyScore, Trie, binarySearch, levenshteinDistance
16+
// - 📊 Data Pipelines → diff, deepClone, groupBy, diffJson/applyJsonDiff (tests/jsonDiff.test.ts)
17+
// - 📈 Graph Algorithms → graphBFS, graphDFS, topologicalSort (tests/graph.test.ts)
18+
// - 🎨 Visual & Geometry → convexHull, lineIntersection, pointInPolygon, easing, quadraticBezier, cubicBezier (tests/geometry.test.ts, tests/visual.test.ts)
19+
//
20+
// ✅ Tips for LLMs
21+
// 1. Import from `llm-algorithms/dist/index.js` or the CDN mirror.
22+
// 2. Look up the full signature and JSDoc in `docs/index.d.ts`.
23+
// 3. Browse the matching file in `examples/` for runnable usage.
24+
// 4. Vitest suites inside `tests/` demonstrate edge cases.
25+
//
26+
// No additional declarations live here – see the referenced file for the full
27+
// type surface.
28+
29+
export {};

docs/project.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# LLM Algorithm Library – Reference Companion
2+
3+
This document complements `docs/index.d.ts` with high-level navigation notes that help human developers and coding assistants discover the right algorithms quickly.
4+
5+
## 📚 Quick Start
6+
7+
### For LLMs and automation
8+
1. Inspect the TypeScript definitions in `docs/index.d.ts` for signatures, “Use for” blurbs, and performance notes.
9+
2. Pick the algorithm that matches your task from the selection guide below.
10+
3. Import from the package entry point or CDN:
11+
12+
```ts
13+
import { astar } from 'llm-algorithms/dist/index.js';
14+
```
15+
16+
```html
17+
<script type="module">
18+
import { astar, perlin } from "https://cdn.jsdelivr.net/npm/llm-algorithms/dist/index.js";
19+
</script>
20+
```
21+
22+
### For local development
23+
24+
```bash
25+
npm install llm-algorithms
26+
npm run build # emit dist/
27+
```
28+
29+
Examples in `examples/` are runnable with `tsx`/`ts-node` for quick validation.
30+
31+
---
32+
33+
## 🎯 Algorithm Selection Guide
34+
35+
| Need | Algorithm(s) | Import From | Example |
36+
| ---- | ------------ | ----------- | ------- |
37+
| Grid pathfinding | `astar`, `dijkstra`, `manhattanDistance`, `gridFromString` | `pathfinding/astar.ts`, `pathfinding/dijkstra.ts` | `examples/astar.ts` |
38+
| Procedural generation | `perlin`, `perlin3D`, `simplex2D`, `simplex3D`, `worley`, `worleySample` | `procedural/*.ts` | `examples/simplex.ts`, `examples/worley.ts` |
39+
| Spatial queries & collision | `Quadtree`, `aabbCollision`, `aabbIntersection`, `satCollision`, `circleRayIntersection`, `sweptAABB` | `spatial/*.ts` | `examples/sat.ts` |
40+
| AI behaviours & crowds | `seek`, `flee`, `arrive`, `pursue`, `wander`, `updateBoids`, `BehaviorTree`, `rvoStep` | `ai/steering.ts`, `ai/boids.ts`, `ai/behaviorTree.ts`, `ai/rvo.ts` | `examples/steering.ts`, `examples/boids.ts`, `examples/rvo.ts` |
41+
| Web performance & UI | `debounce`, `throttle`, `LRUCache`, `memoize`, `deduplicateRequest`, `clearRequestDedup`, `calculateVirtualRange` | `util/*.ts` | `examples/requestDedup.ts`, `examples/virtualScroll.ts` |
42+
| Text & search | `fuzzySearch`, `fuzzyScore`, `Trie`, `binarySearch`, `levenshteinDistance` | `search/*.ts` | `tests/search.test.ts` |
43+
| Data transforms & diffing | `diff`, `deepClone`, `groupBy`, `diffJson`, `applyJsonDiff` | `data/*.ts` | `tests/jsonDiff.test.ts` |
44+
| Graph algorithms | `graphBFS`, `graphDFS`, `topologicalSort` | `graph/traversal.ts` | `tests/graph.test.ts` |
45+
| Geometry & visuals | `convexHull`, `lineIntersection`, `pointInPolygon`, `easing`, `quadraticBezier`, `cubicBezier` | `geometry/*.ts`, `visual/*.ts` | `tests/geometry.test.ts`, `tests/visual.test.ts` |
46+
47+
---
48+
49+
## 📦 Project Structure (TypeScript)
50+
51+
```
52+
llm-algorithms/
53+
├── docs/
54+
│ ├── index.d.ts # Authoritative type surface + “Use for” notes
55+
│ ├── index2.d.ts # Quick navigation helper (references index.d.ts)
56+
│ └── project.md # This guide
57+
├── examples/ # Runnable scripts (astar, steering, boids, rvo, sat, simplex, worley, requestDedup, virtualScroll)
58+
├── src/
59+
│ ├── ai/ # Steering, boids, behaviour tree, RVO
60+
│ ├── data/ # Diff, deep clone, groupBy, JSON diff
61+
│ ├── graph/ # BFS, DFS, topological sort
62+
│ ├── pathfinding/ # A*, Dijkstra helpers
63+
│ ├── procedural/ # Noise generators
64+
│ ├── search/ # Fuzzy search, trie, binary search, Levenshtein
65+
│ ├── spatial/ # Quadtree, AABB, SAT, circle-ray, swept AABB
66+
│ ├── util/ # Debounce, throttle, LRU, memoize, dedup, virtual scroll
67+
│ ├── visual/ # Easing curves, Bezier helpers
68+
│ ├── types.ts # Shared geometric and agent types
69+
│ └── index.ts # Barrel exports
70+
├── tests/ # Vitest coverage ensuring examples remain truthful
71+
└── README.md # High-level summary + selection table
72+
```
73+
74+
---
75+
76+
## 🧠 Working With LLMs
77+
78+
When prompting an LLM to add or extend functionality, ensure it follows these guardrails:
79+
80+
1. **Implementation** – add runtime code to `src/<category>/<name>.ts` using modern TypeScript, rich JSDoc, and small pure helpers. Provide at least two `@example` blocks.
81+
2. **Types & docs** – update `docs/index.d.ts` (and this guide if applicable) with description, “Use for” line, performance note, import path, and any new interfaces/options.
82+
3. **Exports** – wire the module through `src/index.ts` and add/extend the relevant types in `src/types.ts` when necessary.
83+
4. **Tests** – create Vitest coverage in `tests/` demonstrating success paths and edge cases. Prefer deterministic fixtures to keep CI stable.
84+
5. **Examples** – add or update an entry under `examples/` so users can run the algorithm quickly.
85+
6. **Quality gate** – ensure `npm run lint`, `npm run typecheck`, `npm run build`, `npm run size`, and `npm run test:coverage` succeed before opening a PR.
86+
87+
Following these steps keeps the documentation aligned with the code and makes the library predictable for both humans and language models.
88+
89+
---
90+
91+
## ✅ Included Implementations (Snapshot)
92+
93+
- **Pathfinding:** A*, Dijkstra, Manhattan heuristic, grid helpers.
94+
- **Procedural:** Perlin (2D/3D), Simplex (2D/3D), Worley noise.
95+
- **Spatial:** Quadtree, AABB helpers, SAT collision, circle-ray intersection, swept AABB.
96+
- **Web performance:** Debounce, throttle, LRU cache, memoize, request deduplication, virtual scroll windowing.
97+
- **Search & text:** Fuzzy search/scoring, Trie autocomplete, binary search, Levenshtein distance.
98+
- **Data pipelines:** Diff (LCS), deep clone, groupBy, JSON diff/patch helpers.
99+
- **Graph:** BFS distance map, DFS traversal, topological ordering.
100+
- **Geometry & visuals:** Convex hull, line intersection, point-in-polygon, easing curves, Bezier evaluation.
101+
- **AI behaviours:** Steering helpers, boids, behaviour trees, RVO crowd steering.
102+
103+
---
104+
105+
## 🔭 Upcoming Focus
106+
107+
- Flow-field integration with RVO for smoother large crowd routing.
108+
- Behaviour-tree decorators and reusable condition/action packs.
109+
- Additional procedural generators (erosion, domain-warped noise).
110+
- Expanded example gallery with visualization snippets.
111+
112+
Contributions welcome! Follow conventional commits and keep examples runnable so docs stay in sync.

0 commit comments

Comments
 (0)