resolve gene type issues

This commit is contained in:
Michael Peters 2024-08-09 13:49:34 -07:00
parent 7997fa435b
commit 85c6731036
2 changed files with 10 additions and 2 deletions

View File

@ -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<EdgeT extends Edge<Node<EdgeT>>> {
interface Gene {
innovation: number;
src: NodeID;
dst: NodeID;
src_id: NodeID;
dst_id: NodeID;
weight: number;
enabled: boolean;
}

View File

@ -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');