This release is 169 versions behind 0.174.5 — 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, assertNotEquals } from "jsr:@std/assert@^1.0.8"; import { Creature, CreatureUtil } from "../../mod.ts"; import { randomConnectMissing } from "../../src/reconstruct/ConnectMissing.ts"; import type { SynapseExport } from "../../src/architecture/SynapseInterfaces.ts"; Deno.test("ConnectMissing", () => { const creature = new Creature(10, 3); const uuid1 = CreatureUtil.makeUUID(creature); assert(uuid1); const exported = creature.exportJSON(); exported.input = 20; const creature2 = Creature.fromJSON(exported); const uuid2 = CreatureUtil.makeUUID(creature2); const creature3 = randomConnectMissing(creature2); const uuid3 = CreatureUtil.makeUUID(creature3); assertNotEquals(uuid2, uuid3); delete creature2.uuid; const uuid2b = CreatureUtil.makeUUID(creature2); assert(uuid2b === uuid2); const exported3 = creature3.exportJSON(); console.log(exported3); assert(exported3.input === 20); const inputMissing = new Set<number>(); for (let i = 0; i < exported3.input; i++) { inputMissing.add(i); } exported3.synapses.forEach((synapse: SynapseExport) => { if (synapse.fromUUID.startsWith("input")) { inputMissing.delete(parseInt(synapse.fromUUID.split("-")[1])); } }); assert( inputMissing.size === 0, `Not all inputs are connected to the brain. ${inputMissing.size} missing inputs: ${ Array.from(inputMissing).join(",") }`, ); }); Deno.test("ConnectMissing-All-present", () => { const creature = new Creature(10, 3); const uuid1 = CreatureUtil.makeUUID(creature); assert(uuid1); const creature2 = randomConnectMissing(creature); const uuid2 = CreatureUtil.makeUUID(creature2); assert(uuid1 === uuid2); });