public override bool Equals(object obj) { if (obj == null) { return(false); } if (this == obj) { return(true); } NEATNetwork ind = (NEATNetwork)obj; //if the nodes or incoming and outgoing are different, they are different networks if (ind.Nodes.Count != Nodes.Count || ind.Inputs.Count != Inputs.Count || ind.Outputs.Count != Outputs.Count) { return(false); } for (int i = 0; i < ind.Nodes.Count; i++) { if (!ind.Nodes[i].Equals(Nodes[i])) { return(false); } } for (int i = 0; i < ind.Inputs.Count; i++) { if (!ind.Inputs[i].Equals(Inputs[i])) { return(false); } } for (int i = 0; i < ind.Outputs.Count; i++) { if (!ind.Outputs[i].Equals(Outputs[i])) { return(false); } } return(true); }
/** Return the depth of this node in the network. */ public int Depth(int d, NEATNetwork network, int maxDepth) { if (d > 100) { // original code use these number in code, need to find a good way // to justify these return(10); } // Base case if (this.Type == NodeType.SENSOR) { return(d); } d++; // recursion int curDepth = 0; // The depth of current node for (int i = 0; i < IncomingGenes.Count; ++i) { NEATNode node = IncomingGenes[i].InNode; if (!node.IsTraversed) { node.IsTraversed = true; curDepth = node.Depth(d, network, maxDepth); node.InnerLevel = curDepth - d; } else { curDepth = d + node.InnerLevel; } maxDepth = Math.Max(curDepth, maxDepth); } return(maxDepth); }