/// <summary> /// Gets the hash code of a potential connection gene pattern. Based off the innovation numbers of the given node gene patterns. /// </summary> /// <param name="pedigree">The owning pedigree of the potential connection gene pattern.</param> /// <param name="from">The from node of the potential connection gene pattern.</param> /// <param name="to">The to node of the potential connection gene pattern.</param> /// <returns>The hash code.</returns> /// <exception cref="ArgumentNullException">When from/to is null.</exception> public static int GetHashCode(Pedigree pedigree, NodeGenePattern from, NodeGenePattern to) { Helpers.ThrowOnNull(from, "from"); Helpers.ThrowOnNull(to, "to"); return(from.InnovationNumber * pedigree.MaxNodes + to.InnovationNumber); }
/// <summary> /// Constructs a connection gene pattern with the given innovation number, from/to nodes, and replacing number. /// </summary> /// <param name="pedigree">The owning pedigree of this connection gene pattern.</param> /// <param name="innovation_number">The innovation number.</param> /// <param name="from">The NodeGene to connect from.</param> /// <param name="to">The NodeGene to connect to.</param> /// <param name="replacing_number">The innovation number of the node that replaces this connection.</param> /// <exception cref="ArgumentNullException">When from/to is null.</exception> protected internal ConnectionGenePattern(Pedigree pedigree, int innovation_number, NodeGenePattern from, NodeGenePattern to, int replacing_number) : base(pedigree, innovation_number) { Helpers.ThrowOnNull(from, "from"); Helpers.ThrowOnNull(to, "to"); From = from; To = to; ReplacingNumber = replacing_number; }
/// <summary> /// Constructs a node gene pattern with the given innovation number and X position. /// </summary> /// <param name="pedigree">The owning pedigree of this node gene pattern.</param> /// <param name="innovation_number">The innovation number.</param> /// <param name="x">The X position of the node.</param> protected internal NodeGenePattern(Pedigree pedigree, int innovation_number, double x) : base(pedigree, innovation_number) { X = x; }
/// <summary> /// Constructs a gene pattern with the given pedigree and innovation number. /// </summary> /// <param name="pedigree">The owning pedigree of this gene pattern.</param> /// <param name="innovation_number">The innovation number.</param> public GenePattern(Pedigree pedigree, int innovation_number) { Pedigree = pedigree; InnovationNumber = innovation_number; }