From 4195c08745036d89a361e5c1f9d0a386871073ee Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Wed, 1 Jul 2015 17:32:04 +0200 Subject: [PATCH] crashes workaround. working on better fix --- core/src/logic/neural/Brain.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/logic/neural/Brain.java b/core/src/logic/neural/Brain.java index 7c20a85..9183b96 100644 --- a/core/src/logic/neural/Brain.java +++ b/core/src/logic/neural/Brain.java @@ -94,12 +94,15 @@ public class Brain { } public float[][][] mutate(float mutationFactor) { - float[][][] res = new float[neurons.length][neurons[1].length][neurons[1].length]; + float[][][] res = new float[neurons.length][][]; for (int i = 0; i < neurons.length; i++) // layers { - for (int j = 0; i < neurons[i].length; j++) // neurons per layer + res[i] = new float[neurons[i].length][]; + for (int j = 0; j < neurons[i].length; j++) // neurons per layer { - res[i][j] = neurons[i][j].mutate(mutationFactor); + if (neurons[i][j] != null) { + res[i][j] = neurons[i][j].mutate(mutationFactor); + } } } return res;