Example #1
0
        static bool CrosbreedBestTwo(ResultsContainer resultsContainer, out List <Gene> listGenesChild)
        {
            listGenesChild = null;

            ResultItem[] arrayCandidates;

            bool areCandidatesFound = FindCrosbreedCandidates(resultsContainer, out arrayCandidates);

            if (areCandidatesFound)
            {
                return(ProduceChild(arrayCandidates[0].ListActiveGenes, arrayCandidates[1].ListActiveGenes, out listGenesChild));
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        static bool FindCrosbreedCandidates(ResultsContainer resultsContainer, out ResultItem[] arrayCandidates)
        {
            arrayCandidates = null;

            List <ResultItem> listBestToWorst = resultsContainer.SortByScore();

            if (listBestToWorst.Count < 2)
            {
                return(false);
            }

            arrayCandidates = new ResultItem[2];

            arrayCandidates[0] = listBestToWorst[0];
            arrayCandidates[1] = listBestToWorst[1];

            return(true);
        }
Example #3
0
        public bool CrossBreed(ResultsContainer resultsContainer)
        {
            List <Gene> listGenesChild;

            if (CrosbreedBestTwo(resultsContainer, out listGenesChild))
            {
                _listActiveGenes.Clear();

                foreach (var gene in listGenesChild)
                {
                    _listActiveGenes.Add(gene);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }