Ejemplo n.º 1
0
        public static void TestPlayabilityFromLevelsFile(string path, bool isSaveImage)
        {
            //OpenFileDialog op = new OpenFileDialog();
            //op.Title = @"Choose levels file";
            String pathReader = path;
            //if (op.ShowDialog() == DialogResult.OK)
            //{
            //    pathReader = op.FileName;
            //}
            StreamReader sr           = new StreamReader(pathReader);
            StreamWriter sw           = new StreamWriter(@"ResultsPlayabilityCheck.txt", true);
            String       currentLevel = String.Empty;

            while ((currentLevel = sr.ReadLine()) != null)
            {
                LevelBuilder.CreateRestedLevel(currentLevel, true);
                RyseAgent agent = new RyseAgent(10);
                agent.IsSaveImage               = isSaveImage;
                agent.maxDepthArr               = 0;
                agent.prologTime                = 0;
                agent.nodesExplored             = 0;
                agent.bestClosestFrogCookieDist = Double.MaxValue;
                agent.bestPerformedActions      = new List <Action>();
                agent.Simulator = new PlayabilitySimulatorEngineProlog(agent.IsSaveImage);
                bool           playability      = false;
                List <Action>  performedActions = new List <Action>();
                List <Vector3> performedVel     = new List <Vector3>();

                DateTime   d1   = DateTime.Now;
                ActionNode node = new ActionNode(new VoidAction());
                agent.SimulatePlayability(node, StaticData.EngineManager, ref playability, 0, performedActions, performedVel, 0, PlayabilityCheckMode.NormalCheck);
                DateTime d2 = DateTime.Now;
                agent.totalTime = (int)((d2 - d1).TotalSeconds);

                // Write to file

                sw.WriteLine(playability
                             + "\t" + agent.prologTime / 1000
                             + "\t" + agent.totalTime
                             + "\t" + String.Format("{0:0.00}", agent.bestClosestFrogCookieDist)
                             + "\t" + agent.maxDepthArr
                             + "\t" + agent.nodesExplored
                             + "\t" + currentLevel
                             + "\t" + HelperModules.GenericHelperModule.GetActionsString(agent.bestPerformedActions)
                             );
                Console.WriteLine(playability);
                // write to db
                //DatabaseHandler.InsertToPlayabilityTestTable(1,
                //                                             playability,
                //                                             prologTime / 1000,
                //                                             totalTime,
                //                                             String.Format("{0:0.00}", bestClosestFrogCookieDist),
                //                                             maxDepthArr,
                //                                             nodesExplored,
                //                                             _strLevel,
                //                                             HelperModules.GenericHelperModule.GetActionsString(bestPerformedActions));
                sw.Flush();
            }
            sw.Close();
        }
Ejemplo n.º 2
0
        public static void WatchLivePlayabilityFromLevelsActionsFiles()
        {
            //for (int i = 3; i < 6; i++)
            //{
            string       path = "160LevelSameCompsPlayable.txt";// "LevelsActions.txt";
            StreamReader sr   = new StreamReader(path);
            string       line = String.Empty;

            while ((line = sr.ReadLine()) != null)
            {
                LevelBuilder.CreateRestedLevel(line.Split('\t')[12], false);
                RyseAgent agent = new RyseAgent(10);
                agent.IsSaveImage = false;

                StaticData.GameSessionMode = SessionMode.PlayingMode;
                //EngineShotsManager.ShowXNAWindow();
                LivePlayabilitySimulator simulator = new LivePlayabilitySimulator(StaticData.EngineManager);
                simulator.SimulateNewWindow(new ActionsGenerator(line.Split('\t')[13]).Actions);
            }
            sr.Close();
            //}
        }
Ejemplo n.º 3
0
        public static void WatchLivePlayabilityFromLevelsActionsFilesAllCompsForDesigner(int levelNr)
        {
            string       path    = @"C:\CTREngine\100 Playability PPr.txt";
            StreamReader sr      = new StreamReader(path);
            string       line    = String.Empty;
            int          counter = 0;

            while ((line = sr.ReadLine()) != null)
            {
                if (counter == levelNr)
                {
                    DesignEnhanceManager.GevaLevel          = line.Split('\t')[12];
                    DesignEnhanceManager.PlayabilityActions = line.Split('\t')[13];
                    LevelBuilder.CreateRestedLevel(DesignEnhanceManager.GevaLevel, false);
                    RyseAgent agent = new RyseAgent(10);
                    agent.IsSaveImage = false;
                    StaticData.SetEngineManagerLastLevel(ObjectSerializer.DeepCopy(StaticData.EngineManager));
                    break;
                }
                counter++;
            }
            sr.Close();
        }
Ejemplo n.º 4
0
        //"cookie( 300 , 120 ) frog( 360 , 300 )  rope( 550 , 50 , 100 ) rope( 440 , 50 , 180 ) blower( 490 , 180 , 4 )";
        //"cookie(405, 130)  frog(320, 70)  rope(0, 326, 116, 100)  rope(1, 705, 149, 180)  rocket(672, 351, 5) bump(300, 150, 1) bump(300, 200, 1) bump(300, 250, 1)  bump(300, 300, 1)";

        //"cookie(405, 130)  frog(400, 418)  rope(0, 326, 116, 100)  rope(1, 705, 149, 180)  bubble(7, 672, 351) rocket(720, 60, 3) bump(300, 150, 1) bump(300, 200, 1) bump(300, 250, 1)  bump(300, 300, 1)";
        //"cookie(405, 130)  frog(450, 450)  rope(1, 705, 149, 180)  rocket(672, 351, 5) bump(300, 150, 1) bump(300, 200, 1) bump(300, 250, 1)  bump(300, 300, 1)";

        //"cookie(471, 99)  frog(336, 426)  rope(0, 315, 44, 60)  rope(1, 455, 43, 100)  rope(2, 690, 31, 170)  blower(680, 400, 4)  bubble(0, 600, 320)  rocket(458, 262, 3)  bump(715, 165, 2)  bump(714, 236, 2)  bump(475, 206, 0)  bump(409, 207, 0)  bump(339, 207, 0)  bump(502, 381, 5)  bump(526, 442, 2) bump(526, 520, 2)";
        //"cookie(471, 99)  frog(336, 426)  rope(2, 620, 31, 170)  blower(650, 400, 4)  bubble(0, 600, 320)  rocket(458, 262, 3)  bump(715, 165, 2)  bump(714, 236, 2)  bump(475, 206, 0)  bump(409, 207, 0)  bump(339, 207, 0)  bump(502, 381, 5)  bump(526, 442, 2) bump(526, 520, 2)";

        //"cookie(471, 99)  frog(336, 426)  rope(2, 620, 31, 170)  blower(650, 350, 4)  bubble(0, 600, 320)  rocket(458, 262, 3)  bump(715, 165, 2)  bump(714, 236, 2)  bump(475, 206, 0)  bump(409, 207, 0)  bump(339, 207, 0)  bump(502, 381, 5)  bump(526, 442, 2) bump(526, 500, 2)";

        //"cookie(700, 239)  frog(356, 408)  rope(0, 706, 103, 180)  blower(746, 232, 4)  bubble(0, 597, 240)  rocket(600, 64, 3) bump(536, 210, 2)  bump(536, 270, 2) bump(536, 339, 2)  bump(537, 408, 2)  bump(537, 478, 2)  ";

        public static void GenerateLevelTesting()
        {
            LevelBuilder.CreateRestedLevel(StrLevelTesting, false);
            String str          = EngineStateManager.GetEngineStateFactStringWithEnterDelimiterToProlog();
            bool   IsDesign     = false;
            bool   isSaveToFile = true;

            if (!IsDesign)
            {
                ActionsExecuterGenSim.IsSaveStateToFile = true;
                RyseAgent agent = new RyseAgent(0);
                agent.IsSaveImage = false;
                agent.Simulator   = new PlayabilitySimulatorEngineProlog(agent.IsSaveImage);
                bool           playability      = false;
                List <Action>  performedActions = new List <Action>();
                List <Vector3> performedVel     = new List <Vector3>();
                EngineManager  engine           = ObjectSerializer.DeepCopy(StaticData.EngineManager);
                DateTime       d1       = DateTime.Now;
                ActionNode     baseNode = new ActionNode(null);
                agent.SimulatePlayability(baseNode, StaticData.EngineManager, ref playability, 0, performedActions, performedVel, 0, PlayabilityCheckMode.NormalCheck);
                DateTime d2 = DateTime.Now;
                agent.totalTime = (int)(d2 - d1).TotalSeconds;
                int avgLevels = 0;
                if (agent.NrOfTerminates > 0)
                {
                    avgLevels = (int)(agent.TerminateLevelSum / agent.NrOfTerminates);
                }
                int nrOfNonVoids =
                    agent.bestPerformedActions.FindAll(delegate(Action a) { return(!(a is VoidAction)); }).Count;
                //FilesHelperModule.PrintTreeToFile(baseNode);
                MessageBox.Show("The level is " + (playability ? "PLAYABLE" : "NOT PLAYABLE") + Environment.NewLine
                                + "Finished processing in = " + agent.totalTime.ToString() + " sec." +
                                Environment.NewLine
                                + "Nodes explored = " + agent.nodesExplored + Environment.NewLine
                                + "Nr of tree cuts = " + agent.NrOfTerminates + Environment.NewLine
                                + "Average tree depth cut = " + avgLevels + Environment.NewLine
                                + "Solution tree depth = " + agent.bestPerformedActions.Count + Environment.NewLine
                                + "Best distance = " + agent.Simulator.ClosestCookieFrogDistance + Environment.NewLine
                                + "Best Performed Actions are = " +
                                HelperModules.GenericHelperModule.GetActionsString(agent.bestPerformedActions) +
                                Environment.NewLine);

                if (isSaveToFile)
                {
                    string strFile = "0"
                                     + "\t" + playability
                                     + "\t" + agent.prologTime / 1000
                                     + "\t" + agent.totalTime
                                     + "\t" + String.Format("{0:0.00}", agent.bestClosestFrogCookieDist)
                                     + "\t" + agent.maxDepthArr
                                     + "\t" + agent.NrOfTerminates
                                     + "\t" + avgLevels
                                     + "\t" + agent.NrLevelterminatesStdMin
                                     + "\t" + agent.NrLevelterminatesStdMax
                                     + "\t" + agent.nodesExplored
                                     + "\t" + agent.bestPerformedActions.Count
                                     + "\t" + nrOfNonVoids
                                     + "\t" + StrLevelTesting
                                     + "\t" +
                                     HelperModules.GenericHelperModule.GetActionsString(agent.bestPerformedActions)
                                     + "\t" + HelperModules.GenericHelperModule.GetVector3ListString(performedVel);

                    StreamWriter sw = new StreamWriter(@"C:\CTREngine\LevelsTestTemp.txt");
                    sw.WriteLine(strFile);
                    sw.Flush();
                    sw.Close();
                }
                StaticData.GameSessionMode = SessionMode.PlayingMode;
                if (!IsDesign)
                {
                    if (playability)
                    {
                        LivePlayabilitySimulator liveSim = new LivePlayabilitySimulator(engine);
                        liveSim.SimulateNewWindow(performedActions);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void GenerateGevaLevelRandPlayabilityFF(String[] args, bool isPrintPositionOnly, bool isSaveImage, int voidInitPlayTotalCount)
        {
            StaticData.EngineManager = null;
            LevelBuilder.CreateRestedLevel(args[1], true);
            RyseAgent agent = new RyseAgent(voidInitPlayTotalCount);

            agent.IsPrintPositionOnly = isPrintPositionOnly;
            agent.IsSaveImage         = isSaveImage;
            agent.Simulator           = new PlayabilitySimulatorEngineProlog(isSaveImage);
            bool           playability      = false;
            EngineManager  engine           = ObjectSerializer.DeepCopy(StaticData.EngineManager);
            DateTime       d1               = DateTime.Now;
            List <Action>  performedActions = new List <Action>();
            List <Vector3> performedVel     = new List <Vector3>();
            double         closestDistSoFar = Double.MaxValue;

            for (int j = 0; j < 10; j++)
            {
                if (!playability)
                {
                    performedActions         = new List <Action>();
                    StaticData.EngineManager = engine;
                    ActionNode node = new ActionNode(new VoidAction());
                    agent.SimulatePlayability(node, StaticData.EngineManager, ref playability, 0, performedActions, performedVel, 0, PlayabilityCheckMode.RandomCheck);
                    if (agent.bestClosestFrogCookieDist < closestDistSoFar)
                    {
                        closestDistSoFar = agent.bestClosestFrogCookieDist;
                    }
                    if (performedActions.Count <= 3)
                    {
                        closestDistSoFar = 70;
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            DateTime d2 = DateTime.Now;

            agent.totalTime = (int)((d2 - d1).TotalMilliseconds);
            StreamWriter swGEVA = new StreamWriter(@"C:\CTREngine\PlayabilityVal_ZGTREngine.txt");

            swGEVA.WriteLine(closestDistSoFar);
            swGEVA.Close();

            int avgLevels = 0;

            if (agent.NrOfTerminates > 0)
            {
                avgLevels = (int)(agent.TerminateLevelSum / agent.NrOfTerminates);
            }
            int nrOfNonVoids =
                agent.bestPerformedActions.FindAll(delegate(Action a) { return(!(a is VoidAction)); }).Count;
            String strFile = "1"
                             + "\t" + playability
                             + "\t" + agent.prologTime / 1000
                             + "\t" + agent.totalTime
                             + "\t" + String.Format("{0:0.00}", agent.bestClosestFrogCookieDist)
                             + "\t" + agent.maxDepthArr
                             + "\t" + agent.NrOfTerminates
                             + "\t" + avgLevels
                             + "\t" + agent.NrLevelterminatesStdMin
                             + "\t" + agent.NrLevelterminatesStdMax
                             + "\t" + agent.nodesExplored
                             + "\t" + agent.bestPerformedActions.Count
                             + "\t" + nrOfNonVoids
                             + "\t" + args[1]
                             + "\t" + HelperModules.GenericHelperModule.GetActionsString(agent.bestPerformedActions)
                             + "\t" + HelperModules.GenericHelperModule.GetVector3ListString(performedVel);

            if (closestDistSoFar <= 50)
            {
                StreamWriter sw = new StreamWriter(@"C:\CTREngine\PhysicsEngine_EvolvePlayActions.txt", true);
                sw.WriteLine(strFile);
                sw.Flush();
                sw.Close();
            }
            {
                StreamWriter sw = new StreamWriter(@"C:\CTREngine\PhysicsEngine_EvolvePlayActionsAllLevels.txt", true);
                sw.WriteLine(strFile);
                sw.Flush();
                sw.Close();
            }
        }