public double Evaluate(List <IChromosome> chromosomeSet)
            {
                PMGGenomeSet GenomeSet = new PMGGenomeSet();

                GenomeSet.ChromosomeSetToGenomeSet(chromosomeSet);
                double finalFitness = 0.0;


                // Convert list of chromosomes to genome set


                PMGSingleGameInstance GInstance = new PMGSingleGameInstance();



                // Parse and build the genome set
                GInstance.GameSet.DecodeGenomeSet(GenomeSet);
                GInstance.BuildInstance(false);



                // Weigh intrinsic/extrinsic
                finalFitness = (Convert.ToDouble(intrinsicWeight) / 2.0) * IntrinsicFitness(GInstance)
                               + (Convert.ToDouble(extrinsicWeight) / 2.0) * ExtrinsicFitness(GInstance);

                return(finalFitness);
//				return RandomizationProvider.Current.GetFloat();
            }
Esempio n. 2
0
 //decode entire genome
 public void DecodeGenomeSet(PMGGenomeSet TobeDecoded)
 {
     _genomeSet = TobeDecoded;
     DecodeActorGenome();
     DecodeActorPosGenome();
     DecodeMethodGenome();
     DecodeEventGenome();
 }
 public void ExportSetToFile(PMGGenomeSet GenomeSet, string filename)
 {
     using (StreamWriter sw = new StreamWriter(filename, false)) {
         foreach (string s in GenomeSet.ExportSerializedGenomeSet())
         {
             sw.WriteLine(s);
         }
     }
 }
            public PMGGenomeSet(PMGGenomeSet GenomeSet)
            {
                Clear();
                actorGenome          = new List <int> (GenomeSet.actorGenome);
                actorPositionsGenome = new List <int> (GenomeSet.actorPositionsGenome);

                foreach (List <int> eSet in GenomeSet.eventGenome)
                {
                    eventGenome.Add(eSet);
                }

                foreach (List <int> mSet in GenomeSet.methodGenome)
                {
                    methodGenome.Add(mSet);
                }
            }
        public PMGGenomeSet ImportFromFile(string filename)
        {
            PMGGenomeSet ret = new PMGGenomeSet();

            if (!System.IO.File.Exists(filename))
            {
                return(null);
            }

            string[] lines = System.IO.File.ReadAllLines(filename);

            if (lines.Length != 4)
            {
                return(null);
            }

            if (!ret.ImportSerializedGenomeSet(lines.ToList()))
            {
                return(null);
            }

            return(ret);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            PMGGenomeSet testset = new PMGGenomeSet();

            testset.TestPMGGenomeSet();
            PMGGenomeParse Parsedtestset = new PMGGenomeParse();

            Parsedtestset.DecodeGenomeSet(testset);
            PMGSingleGameInstance testGameInstance = new PMGSingleGameInstance();

            //decodes the entire set
            //testGameInstance.ParsedSet.DecodeGenomeSet(testset);
            testGameInstance.SetInternalParsedSet(Parsedtestset);
            testGameInstance.BuildInstance(true);



            /*/test find one actor's event's method's value function
             * if (debug)
             * {
             *  Console.WriteLine("Total number of created actor : " + CreatedActors.Count);
             *  Console.WriteLine("first actor's first event's first method's first executelist's first step: " + CreatedActors[0].Events[0]._method._steps[0]._functions[0].Type);
             *
             * }
             *
             * /*///jsut for checking that genomes got correctly decoded
            //testGameInstance.ParsedSet.DisplayActorTypeList();
            //testGameInstance.ParsedSet.DisplayActorTypePossplit3List();

            //genome error report
            //testGameInstance.ParsedSet.GenomeSetErrorReport();


            bool programRunning = true;
            bool programPaused  = false;


            //pretend update function
            for (int timestep = 0; timestep < 2; timestep++)
            {
                Console.WriteLine("-- T = {0} --", timestep);
                testGameInstance.UpdateActors();
            }
            // Console.WriteLine("X: "+e.position[0]+"Y: "+e.position[1]);

            /*/pretedn update function
             * while (programRunning)
             * {
             *
             *  if (Keyboard.IsKeyDown(Key.Q))
             *  {
             *      programRunning = false;
             *  }
             *  if (Keyboard.IsKeyDown(Key.P))
             *  {
             *      programPaused = true;
             *  }
             *  if (!programPaused)
             *  {
             *      //Console.WriteLine("-- T = {0} --", i);
             *      testGameInstance.UpdateActors();
             *
             *
             *      i++;
             *  }
             *
             *
             *
             * }//*/
            Console.ReadKey();
        }