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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364import { assert } from "jsr:@std/assert@^1.0.8"; import { Creature } from "../src/Creature.ts"; import type { CreatureInternal } from "../src/architecture/CreatureInterfaces.ts"; import { AddNeuron } from "../src/mutate/AddNeuron.ts"; ((globalThis as unknown) as { DEBUG: boolean }).DEBUG = true; Deno.test("inward", () => { const json: CreatureInternal = { neurons: [ { type: "input", squash: "LOGISTIC", index: 0 }, { type: "input", squash: "LOGISTIC", index: 1 }, { type: "input", squash: "LOGISTIC", index: 2 }, { type: "output", squash: "IF", index: 3, bias: 0, }, ], synapses: [ { from: 2, to: 3, weight: 1, type: "positive" }, { from: 1, to: 3, weight: 1, type: "condition" }, { from: 0, to: 3, weight: 1, type: "negative" }, ], input: 3, output: 1, }; const creature = Creature.fromJSON(json); const connects = creature.inwardConnections(3); assert(connects.length == 3, "expected 3 got " + connects.length); const connects2 = creature.inwardConnections(3); assert(connects2.length == 3, "expected 3 got " + connects2.length); const addNeuron = new AddNeuron(creature); addNeuron.mutate(); let foundPositive = false; let foundNegative = false; let foundCondition = false; creature.synapses.forEach((c) => { if (c.type == "positive") { foundPositive = true; } else if (c.type == "condition") { foundCondition = true; } else if (c.type == "negative") { foundNegative = true; } }); assert(foundPositive, "should have found a positive link"); assert(foundNegative, "should have found a negative link"); assert(foundCondition, "should have found a condition link"); const connects4 = creature.inwardConnections(4); assert(connects4.length >= 3, "expected at least 3 got " + connects4.length); });