This release is 136 versions behind 0.168.1 — the latest version of @stsoftware/neat-ai. Jump to latest
@stsoftware/neat-ai@0.121.0Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
NEAT Neural Network. This project is a unique implementation of a neural network based on the NEAT (NeuroEvolution of Augmenting Topologies) algorithm, written in DenoJS using TypeScript.
import { assert } from "jsr:@std/assert@^1.0.8"; import { emptyDirSync } from "jsr:@std/fs@^1.0.6"; import type { NeatOptions } from "../src/config/NeatOptions.ts"; import { Creature } from "../src/Creature.ts"; ((globalThis as unknown) as { DEBUG: boolean }).DEBUG = true; Deno.test("storePopulation", async () => { const network = new Creature(2, 1, { layers: [ { count: 2 }, ], }); const ts = []; for (let i = 100; i--;) { for (let j = 100; j--;) { if (i == 50) continue; const item = { input: [i, j], output: [Math.sqrt(i * i + j * j)], }; ts.push(item); } } const dir = ".creatures"; emptyDirSync(".creatures"); const options: NeatOptions = { iterations: 10, creatureStore: dir, threads: 1, }; await network.evolveDataSet(ts, options); let creatureCount = 0; for (const dirEntry of Deno.readDirSync(dir)) { if (dirEntry.name.endsWith(".json")) { creatureCount++; } } assert( creatureCount > 1, "Should have stored the creatures was: " + creatureCount, ); });