Skip to content

Commit

Permalink
Fixed bug when FastModularNetworkSolver returned outputs as slice o…
Browse files Browse the repository at this point in the history
…f internal signals array. Thus, it made it possible to change solver state by modifying values in the returned slice.
  • Loading branch information
yaricom committed Jun 23, 2022
1 parent 10fb58f commit ac60a6c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion neat/network/fast_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ func (s *FastModularNetworkSolver) LoadSensors(inputs []float64) error {

// ReadOutputs Read output values from the output nodes of the network
func (s *FastModularNetworkSolver) ReadOutputs() []float64 {
return s.neuronSignals[s.sensorNeuronCount : s.sensorNeuronCount+s.outputNeuronCount]
// decouple and return
outs := make([]float64, s.outputNeuronCount)
copy(outs, s.neuronSignals[s.sensorNeuronCount:s.sensorNeuronCount+s.outputNeuronCount])
return outs
}

// NodeCount Returns the total number of neural units in the network
Expand Down

0 comments on commit ac60a6c

Please sign in to comment.