public void BuildStructure(EvaluatableOrganism organism) { if (!organism.Id.Equals(OrganismId)) { throw new Exception("The buildStructure function was passed a different organism then its OrganismId."); } InNode = organism.GetNodeFromIdentifier(InNodeIdentifier); OutNode = organism.GetNodeFromIdentifier(OutNodeIdentifier); if (!Enabled) { return; } switch (OutNode) { case EvaluatableOutputNode eo: eo.AddDependency(this); break; case EvaluatableHiddenNode eh: eh.AddDependency(this); break; default: throw new ArgumentOutOfRangeException(); } }
public void Test(EvaluatableOrganism evaluatableOrganism) { double error = 0; for (int i = 0; i <= 1; i++) { for (int j = 0; j <= 1; j++) { double[] output = evaluatableOrganism.Evaluate(new double[] { i, j, 1 }); double expected = i ^ j; error += Math.Abs(expected - output[0]); } } double score = 4 - error; evaluatableOrganism.Score = score; }