private void bRunAgent_Click(object sender, EventArgs e)
        {
            //Thread t = new Thread(() =>
            //    {
            Game1 game = StaticData.EngineManager.Game1;

            PairCTP.Sort(PairCTPComparator);
            GenSimAgentWrapper agent = new GenSimAgentWrapper(this.PairCTP, 20, false);

            agent.ScatterComps();

            StaticData.EngineManager.Game1 = game;
            if (agent.WAgent.IsSuccess)
            {
                LevelBuilder.CreateRestedLevel(agent.WAgent.LevelStr, false);
                CTRLevelDesigner.SaveEngineState();
                StaticData.GameSessionMode = SessionMode.PlayingMode;
                LivePlayabilitySimulator simulator = new LivePlayabilitySimulator(StaticData.EngineManager);
                simulator.SimulateSameWindow(agent.WAgent.Actions);
            }
            else
            {
                MessageBox.Show("Max number of try is reached. Run the agent again.");
            }

            //});
            //t.Start();
        }
 private void bCheckPlayabilty_Click(object sender, EventArgs e)
 {
     try
     {
         RYSEGenManager.SimulatePlayabiltityFromDesigner();
         SaveEngineState();
         try
         {
             if (DesignEnhanceManager.PlayabilityActions != String.Empty)
             {
                 LevelBuilder.CreateRestedLevel(DesignEnhanceManager.GevaLevel, false);
                 //RYSEManager manager = new RYSEManager(10);
                 //manager.IsSaveImage = false;
                 StaticData.GameSessionMode = SessionMode.PlayingMode;
                 //EngineShotsManager.ShowXNAWindow();
                 LivePlayabilitySimulator simulator = new LivePlayabilitySimulator(StaticData.EngineManager);
                 simulator.SimulateSameWindow(new ActionsGenerator(DesignEnhanceManager.PlayabilityActions).Actions);
             }
         }
         catch (Exception)
         {
         }
     }
     catch (Exception)
     {
     }
 }
        private static void SimulateOnWindow(GenSimAgent agent)
        {
            LevelBuilder.CreateRestedLevel(agent.LevelStr, false);
            StaticData.GameSessionMode = SessionMode.PlayingMode;
            LivePlayabilitySimulator simulator = new LivePlayabilitySimulator(StaticData.EngineManager);

            simulator.SimulateNewWindow(agent.Actions, false, false);
        }
Exemple #4
0
        public static void WatchLivePlayabilityGenSimLevels()
        {
            //for (int i = 3; i < 6; i++)
            //{
            string       path = @"C:\CTREngine\GenSimLevelsPlayable.txt";// "LevelsActions.txt";
            StreamReader sr   = new StreamReader(path);
            string       line = String.Empty;

            while ((line = sr.ReadLine()) != null)
            {
                LevelBuilder.CreateRestedLevel(line.Split('\t')[5], false);


                //EngineShotsManager.ShowXNAWindow();
                ActionsExecuterGenSim.RyseFreq = false;
                LivePlayabilitySimulator simulator = new LivePlayabilitySimulator(StaticData.EngineManager);
                simulator.SimulateNewWindow(new ActionsGenerator(line.Split('\t')[7]).Actions);
            }
            sr.Close();
            //}
        }
Exemple #5
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();
            //}
        }
Exemple #6
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);
                    }
                }
            }
        }