コード例 #1
0
        private static void AddSurvivorsToGenePool()
        {
            foreach (KeyValuePair <string, GeneData> keyValuePair in teamNameToGeneDataDic)
            {
                string   teamName = keyValuePair.Key;
                GeneData geneData = keyValuePair.Value;

                int teamPopCount = TeamManager.GetTeamPopulationCount(teamName);
                int winCount     = 1 + teamPopCount - AverageTeamPopulationCount();

                if (winCount <= 0)
                {
                    // Losers don't get laid
                    continue;
                }

                // Have to place a cap on number of files, otherwise this would flood the machine
                if (FileIOManager.GetFileNames().Count < GenePoolDirectoryFileLimit)
                {
                    LogUtility.LogInfoFormat(
                        "{0} writes DNA to disk",
                        teamName);

                    geneData.DNA.WriteToDisk(FileIOManager.GenerateNewDNAFilePath(winCount));
                }
                else
                {
                    LogUtility.LogInfoFormat(
                        "Gene Pool has reached max size of {0} files",
                        GenePoolDirectoryFileLimit);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Registers the team.
        /// </summary>
        /// <param name="teamName">Team name.</param>
        public static void RegisterTeam(string teamName)
        {
            lock (CommonHelperMethods.GlobalFileIOLock)
            {
                if (!teamNameToGeneDataDic.ContainsKey(teamName))
                {
                    GeneData data = new GeneData(teamName, ChooseDNAParentFile_Random());
                    teamNameToGeneDataDic.Add(teamName, data);
                }
            }

            TeamManager.ResetTeam(teamName);
        }