Exemplo n.º 1
0
        public static int SetFitnessValueForLevel(String[] args)
        {
            GenManager.GenerateGevaLevel(args, null);
            String levelStr = args[1];
            bool   isShortestPathOnlyComparsion = args[2] != "0";

            DateTime         d1 = DateTime.Now;
            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            DateTime d2               = DateTime.Now;
            int      fitness          = Int32.MaxValue;
            int      usedNoRopes      = -1;
            int      generatedNoRopes = -1;
            float    usageFit         = -1;

            if (res.IsPlayable)
            {
                List <List <PolyLog> > chosenPath;
                EntraPathAgent         pathAgent = new EntraPathAgent(entraAgentSimple);
                GetFitnessUsage(pathAgent.AllPaths, levelStr, isShortestPathOnlyComparsion, out usedNoRopes,
                                out generatedNoRopes, out usageFit);
                fitness = (int)(40 * 0 + 60 * usageFit);
            }
            else
            {
                fitness = (int)(40 * MathHelperModule.Normalize((int)res.MinDistToFrog, 200, 50) + 60);
            }

            DateTime d3 = DateTime.Now;

            PrintDataToFiles(d1, d2, d3, res, fitness, args, usageFit, usedNoRopes, generatedNoRopes);
            return(fitness);
        }
Exemplo n.º 2
0
        public static void SetFitnessValueForLevel(String[] args, List <Point> designerPath)
        {
            GenManager.GenerateGevaLevel(args, null);
            bool isOrdering = args[2] != "0";
            //EngineShotsManager shots = new EngineShotsManager();
            //shots.TakeEngineShot(false);
            DateTime d1 = DateTime.Now;

            EntraPlusGenManager.SetFitnessValueForLevel(args);

            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            DateTime d2      = DateTime.Now;
            int      fitness = Int32.MaxValue;

            if (res.IsPlayable)
            {
                EntraPathAgent pathAgent = new EntraPathAgent(entraAgentSimple);
                fitness = pathAgent.GetFitnessValue(designerPath, isOrdering);
            }
            else
            {
                fitness = 100;
                //40 * (int)MathHelperModule.Normalize((int)res.MinDistToFrog, 400, 0) + 60;
            }

            DateTime d3 = DateTime.Now;

            int t1 = (int)(d2 - d1).TotalMilliseconds;
            int t2 = (int)(d3 - d2).TotalMilliseconds;


            //if (res.IsPlayable)
            //PRINTING
            {
                string strFile = "0"
                                 + "\t" + res.IsPlayable
                                 + "\t" + fitness
                                 + "\t" + res.MinDistToFrog
                                 + "\t" + t1
                                 + "\t" + t2
                                 + "\t" + (t1 + t2)
                                 + "\t" + String.Format("{0:0.00}", fitness)
                                 + "\t" + args[1];

                StreamWriter sw = new StreamWriter(@"C:\CTREngine\AllEntraPathEvolvedLevels.txt", true);
                sw.WriteLine(strFile);
                sw.Flush();
                sw.Close();
            }


            StreamWriter swGEVA = new StreamWriter(@"C:\CTREngine\PlayabilityVal_ZGTREngine.txt");

            swGEVA.WriteLine(fitness);
            swGEVA.Close();
        }
Exemplo n.º 3
0
 public EntraPathAgent(EntraAgentSimple entra)
 {
     _entra   = entra;
     _log     = this._entra.PolysLogger.GetLog();
     AllPaths = new List <List <PolyLog> >();
     _frog    = new FrogEntityPoly(this._entra, this._entra.EngineState.FrogRB);
     InitializeFrogPoly();
     SetAllPaths();
 }
Exemplo n.º 4
0
        private static void RunEntraAgent(string[] args)
        {
            IsTestingEntra = true;
            GenManager.GenerateGevaLevel(args, StaticData.EntraImageInput);
            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            EntraDrawer.DrawIntoFileTesting(res.ReachableSpace);
        }
Exemplo n.º 5
0
        public static void ShowTestResult(String[] args)
        {
            GenManager.GenerateGevaLevel(args, StaticData.EntraImageInput);

            //EngineShotsManager shots = new EngineShotsManager();
            //shots.TakeEngineShot(StaticData.EntraImageInput);

            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            EntraDrawer.DrawIntoFileTesting(res.ReachableSpace);

            EntraPathAgent pathAgent = new EntraPathAgent(entraAgentSimple);

            pathAgent.DrawPaths();
        }
Exemplo n.º 6
0
        public static void SetFitnessValueForLevelTest(String[] args, int counter)
        {
            GenManager.GenerateGevaLevel(args, null);
            String levelStr = args[1];
            bool   isShortestPathOnlyComparsion = args[2] != "0";

            DateTime         d1 = DateTime.Now;
            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            DateTime d2               = DateTime.Now;
            int      fitness          = Int32.MaxValue;
            int      usedNoRopes      = -1;
            int      generatedNoRopes = -1;
            float    usageFit         = -1;

            if (res.IsPlayable)
            {
                EntraPathAgent pathAgent = new EntraPathAgent(entraAgentSimple);
                GetFitnessUsage(pathAgent.AllPaths, levelStr, isShortestPathOnlyComparsion, out usedNoRopes,
                                out generatedNoRopes, out usageFit);
                fitness = (int)(40 * 0 + 60 * usageFit);

                EngineShotsManager shots = new EngineShotsManager();
                shots.TakeEngineShot(StaticData.EntraImageInput);
                pathAgent.DrawShortestPath(counter);
            }
            else
            {
                fitness = (int)(40 * MathHelperModule.Normalize((int)res.MinDistToFrog, 300, 50) + 60);
            }

            DateTime d3 = DateTime.Now;

            StreamWriter sw = new StreamWriter(@"PolysTesting\test.txt", true);

            sw.WriteLine(res.IsPlayable + "\t"
                         + fitness + "\t"
                         + usedNoRopes + "\t"
                         + generatedNoRopes + "\t"
                         + String.Format("{0:0.00}", usageFit));
            sw.Close();
            //PrintDataToFiles(d1, d2, d3, res, fitness, args);
        }
Exemplo n.º 7
0
        public static void PrintEffetivceSpace(String[] args, bool withLevelImage, int i)
        {
            if (withLevelImage)
            {
                String strImage = StaticData.EntraImageInput;
                GenManager.GenerateGevaLevel(args, strImage);
                EntraAgentSimple entraAgentSimple = new EntraAgentSimple();

                var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);
                EntraDrawer.DrawIntoFileGeva(res.ReachableSpace, true, i);
            }
            else
            {
                GenManager.GenerateGevaLevel(args, null);
                EntraAgentSimple entraAgentSimple = new EntraAgentSimple();

                var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);
                EntraDrawer.DrawIntoFileGeva(res.ReachableSpace, false, i);
            }
        }
Exemplo n.º 8
0
        public static void SetFitnessValueForLevel(String[] args)
        {
            GenManager.GenerateGevaLevel(args, null);
            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            DateTime         d1      = DateTime.Now;
            float            fitness = 0;


            // Shortcut
            Vector2     cPos = StaticData.EngineManager.CookieRB.PositionXNACenter2D;
            Vector2     fPos = StaticData.EngineManager.FrogRB.PositionXNACenter2D;
            EntraResult res  = null;

            if ((cPos - fPos).Length() < 125)
            {
                fitness = 1000;
            }
            else
            {
                res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);
                if (res.IsPlayable)
                {
                    fitness = 0;
                }
                else
                {
                    fitness = res.MinDistToFrog;
                }
            }
            DateTime d2 = DateTime.Now;


            bool isPlayable = false;

            if (res != null)
            {
                isPlayable = res.IsPlayable;
            }
            else
            {
                isPlayable = false;
            }

            string strFile = "0"
                             + "\t" + isPlayable
                             + "\t" + (d2 - d1).TotalMilliseconds
                             + "\t" + String.Format("{0:0.00}", fitness)
                             + "\t" + args[1];

            if (isPlayable)
            {
                StreamWriter sw = new StreamWriter(@"C:\CTREngine\EntraGenPlayableLevels.txt", true);
                sw.WriteLine(strFile);
                sw.Flush();
                sw.Close();
            }
            else
            {
                StreamWriter sw = new StreamWriter(@"C:\CTREngine\EntraGenNonPlayableLevels.txt", true);
                sw.WriteLine(strFile);
                sw.Flush();
                sw.Close();
            }

            StreamWriter swGEVA = new StreamWriter(@"C:\CTREngine\PlayabilityVal_ZGTREngine.txt");

            swGEVA.WriteLine(fitness);
            swGEVA.Close();
        }