Beispiel #1
0
        static void Main(string[] args)
        {
            ThreeCardPokerFitness fitness = new ThreeCardPokerFitness()
            {
                HandsPerEvaluation = 100,
                Type = ThreeCardPokerFitness.FitnessTypes.SquaredLosses
            };
            EvolutionEngine engine = new EvolutionEngine()
            {
                Parents         = 200,
                Children        = 200,
                FitnessFunction = fitness,
                Generations     = 200
            };
            var initial = new double[][] { new double[] { 1, 1, 1, 1, 1, 1 } };//{ new double[] { 1.0 / 3.0, 0, 1, 0, 1.0 / 3.0, 1.0 } };

            var results = engine.Evolve(initial);

            using (TextWriter writer = new StreamWriter("results.csv"))
            {
                writer.WriteLine("Generation,Fitness,P1_Queen,P1_King,P1_Ace,P2_Queen,P2_King,P2_Ace");
                for (int i = 0; i < results.Generations.Length; i++)
                {
                    writer.Write(i + "," + results.Generations[i].Fitness);
                    for (int j = 0; j < 6; j++)
                    {
                        writer.Write("," + results.Generations[i].Champion[j]);
                    }
                    writer.WriteLine();
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ThreeCardPokerFitness fitness = new ThreeCardPokerFitness()
            {
                HandsPerEvaluation = 100,
                Type = ThreeCardPokerFitness.FitnessTypes.SquaredLosses
            };
            EvolutionEngine engine = new EvolutionEngine()
                {
                    Parents = 200,
                    Children = 200,
                    FitnessFunction = fitness,
                    Generations = 200
                };
            var initial = new double[][] { new double[] { 1, 1, 1, 1, 1, 1 } };//{ new double[] { 1.0 / 3.0, 0, 1, 0, 1.0 / 3.0, 1.0 } };

            var results = engine.Evolve(initial);

            using (TextWriter writer = new StreamWriter("results.csv"))
            {
                writer.WriteLine("Generation,Fitness,P1_Queen,P1_King,P1_Ace,P2_Queen,P2_King,P2_Ace");
                for (int i = 0; i < results.Generations.Length; i++)
                {
                    writer.Write(i + "," + results.Generations[i].Fitness);
                    for (int j = 0; j < 6; j++)
                        writer.Write("," + results.Generations[i].Champion[j]);
                    writer.WriteLine();
                }
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            if (args.Length == 1 && args[0] == "-gen")
            {
                GenerateCondorFile();
                return;
            }

            int handsPerEval = args[0].ToInt();
            int faceoffs     = args[1].ToInt();
            int parents      = args[2].ToInt();

            ThreeCardPokerFitness fitness = new ThreeCardPokerFitness()
            {
                HandsPerEvaluation     = handsPerEval,
                RandomSamplingFaceoffs = faceoffs,
                Type           = ThreeCardPokerFitness.FitnessTypes.SquaredLosses,
                EvalStrategy   = ThreeCardPokerFitness.EvaluationStrategy.UCB1,
                EvaluationType = ThreeCardPokerFitness.EvaluationTypes.RandomSampling
            };

            Console.WriteLine("Hands: {0}", fitness.HandsPerEvaluation);
            Console.WriteLine("Faceoffs: {0}", fitness.RandomSamplingFaceoffs);
            Console.WriteLine("Type: {0}", fitness.Type);
            Console.WriteLine("EvalStrategy: {0}", fitness.EvalStrategy);
            Console.WriteLine("EvalType: {0}", fitness.EvaluationType);
            EvolutionEngine engine = new EvolutionEngine()
            {
                Parents         = parents,
                Children        = parents,
                FitnessFunction = fitness,
                Generations     = 500
            };
            var initial = new double[][] { new double[] { 1, 1, 1, 1, 1, 1 } };//{ new double[] { 1.0 / 3.0, 0, 1, 0, 1.0 / 3.0, 1.0 } };

            var results = engine.Evolve(initial);

            using (TextWriter writer = new StreamWriter(string.Format("sqloss_ucb_results_{0}eval_{1}faceoffs_parents{2}.csv",
                                                                      fitness.HandsPerEvaluation,
                                                                      fitness.RandomSamplingFaceoffs,
                                                                      engine.Parents)))
            {
                writer.WriteLine("Generation,Fitness,P1_Queen,P1_King,P1_Ace,P2_Queen,P2_King,P2_Ace");
                for (int i = 0; i < results.Generations.Length; i++)
                {
                    writer.Write(i + "," + results.Generations[i].Fitness);
                    for (int j = 0; j < 6; j++)
                    {
                        writer.Write("," + results.Generations[i].Champion[j]);
                    }
                    writer.WriteLine();
                }
            }
        }
 public void Evaluate(EvolutionEngine.Individual[] pop)
 {
 }