diff --git a/src/components/snake/brain-neat.ts b/src/components/snake/brain-neat.ts index 32585a3..fb765b3 100644 --- a/src/components/snake/brain-neat.ts +++ b/src/components/snake/brain-neat.ts @@ -185,6 +185,8 @@ import IOSet from './ioset'; export type NodeID = string; +// NOTE: the types here aren't perfect but they are better than the +// complete nightmare that they could be... export interface RawEdge { src_id: NodeID; dst_id: NodeID; @@ -274,8 +276,8 @@ export class Network>> { interface Gene { innovation: number; - src: NodeID; - dst: NodeID; + src_id: NodeID; + dst_id: NodeID; weight: number; enabled: boolean; } diff --git a/src/test/test-brain-neat.ts b/src/test/test-brain-neat.ts index 77d9d69..ffc3e6a 100644 --- a/src/test/test-brain-neat.ts +++ b/src/test/test-brain-neat.ts @@ -33,6 +33,7 @@ function testEdgesToNodesBasic() { Array.from(nodeA.dsts).map(e => e.dst.id), ['C', 'D', 'E'], ); + const nodeB = nodes.get('B')!; assert(nodeB.id === 'B'); assert(nodeB.srcs.size === 0); @@ -41,6 +42,7 @@ function testEdgesToNodesBasic() { Array.from(nodeB.dsts).map(e => e.dst.id), ['D'], ); + const nodeC = nodes.get('C')!; assert(nodeC.id === 'C'); assert(nodeC.srcs.size === 1); @@ -53,6 +55,7 @@ function testEdgesToNodesBasic() { Array.from(nodeC.dsts).map(e => e.dst.id), ['E'], ); + const nodeD = nodes.get('D')!; assert(nodeD.id === 'D'); assert(nodeD.srcs.size === 2); @@ -60,11 +63,13 @@ function testEdgesToNodesBasic() { Array.from(nodeD.srcs).map(e => e.src.id), ['A', 'B'], ); + assert(nodeD.dsts.size === 2); assertArrayEqual( Array.from(nodeD.dsts).map(e => e.dst.id), ['E', 'F'], ); + const nodeE = nodes.get('E')!; assert(nodeE.id === 'E'); assert(nodeE.srcs.size === 3); @@ -72,6 +77,7 @@ function testEdgesToNodesBasic() { Array.from(nodeE.srcs).map(e => e.src.id), ['A', 'C', 'D'], ); + assert(nodeE.dsts.size === 0); const nodeF = nodes.get('F')!; assert(nodeF.id === 'F');