コード例 #1
0
        public FlagColor[] SelectColors(Culture Culture, FlagColorMap Colors, Random Random, int Iterations = 30)
        {
            FlagColor[] Chosen = Colors.Closest(Culture, _Parts.Length);

            Pair <double, int> P = ColoringScore(Culture, Chosen);

            for (int j = 0; j < Iterations; ++j)
            {
                P = ColoringScore(Culture, Chosen);
                int    C     = Random.NextDouble() > .5 ? P.Second : Random.Next(0, _Parts.Length);
                double Score = P.First;

                FlagColor Original = Chosen[C];
                // Find best new assignment
                FlagColor Best = Chosen[C];
                for (int i = 0; i < Colors.Colors.Length; ++i)
                {
                    Chosen[C] = Colors.Colors[i];
                    double thisScore = ColoringScore(Culture, Chosen).First;
                    if (thisScore > Score)
                    {
                        Score = thisScore;
                        Best  = Colors.Colors[i];
                    }
                }
                Chosen[C] = Best;
            }
            return(Chosen);
        }
コード例 #2
0
        public Flag CreateFlag(Culture Culture, FlagColorMap Colors, Random Random)
        {
            FlagTemplate T = _Templates[Random.NextDouble()];

            return(new Flag(T, T.SelectColors(Culture, Colors, Random)));
        }