Пример #1
0
func neuronAddInlinkFrom(neuron *ng.Neuron, sourceNodeId *ng.NodeId) *ng.InboundConnection {

	cortex := neuron.Cortex

	// create weight vector
	weightVectorLength := 1
	if sourceNodeId.NodeType == ng.SENSOR {
		sensor := cortex.FindSensor(sourceNodeId)
		weightVectorLength = sensor.VectorLength
	}
	weights := randomWeights(weightVectorLength)

	// make an inbound connection sourceNodeId <- neuron
	connection := neuron.ConnectInboundWeighted(sourceNodeId, weights)

	// make an outbound connection sourceNodeId -> neuron
	chosenConnector := cortex.FindConnector(sourceNodeId)
	ng.ConnectOutbound(chosenConnector, neuron)

	return connection

}