Beispiel #1
0
        public static Hashtable fixGenome(params string[] genes)
        {
            //helper function for generate

            Hashtable nGenome;

            if (genes.Length % 2 != 0)
            {
                Debug.LogWarning("wrong number of arguments");
                return(generateEmptyGenome(0));
            }
            else
            {
                int counter = 0;
                for (int i = 1; i < genes.Length; i += 2)
                {
                    float[] t = TREEUtils.stringToFloatArray(genes [i]);
                    if (counter < t.Length)
                    {
                        counter = t.Length;
                    }
                }

                nGenome = generateEmptyGenome(counter);

                for (int i = 0; i < genes.Length; i += 2)
                {
                    float[] a = TREEUtils.stringToFloatArray((string)genes [i + 1]);
                    float[] b = nGenome [(string)genes [i]] as float[];
                    TREEUtils.mergeArrays(a, b);
                }
            }
            return(nGenome);
        }