//public long UpdateSoFar = 5 * 60;

        public PlayabilitySimulatorEngineProlog(bool isSaveImage)
        {
            this.IsSaveImage = isSaveImage;
            if (IsSaveImage)
            {
                ShotsManager = new EngineShotsManager();
            }
        }
Example #2
0
 public static void GenerateGevaLevel(String[] args, String imageName = null)
 {
     LevelBuilder.CreateRestedLevelForLevelsShots(args[1], false);
     if (imageName != null)
     {
         EngineShotsManager shotsManager = new EngineShotsManager();
         shotsManager.TakeEngineShot(imageName);
     }
 }
Example #3
0
        public static void GenerateGevaLevel(String[] args, bool isPrintPositionOnly, bool isSaveImage)
        {
            LevelBuilder.CreateRestedLevelForLevelsShots(args[1], isPrintPositionOnly);
            if (isSaveImage)
            {
                EngineShotsManager shotsManager = new EngineShotsManager();
                shotsManager.TakeEngineShot();
            }

            if (isPrintPositionOnly)
            {
                string       pos = EngineStateManager.GetEngineStatePositionsOnlyFactString();
                StreamWriter sw  = new StreamWriter("PhysicsEngine_PositionsOnly.txt", true);
                sw.WriteLine(pos);
                sw.Flush();
                sw.Close();
            }
        }
Example #4
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);
        }
Example #5
0
        public static void ManipulateActions(GameTime gameTime)
        {
            if (IsSimulatingGamePlayability)
            {
                if (ListOfActions != null)
                {
                    if (ActionsNotifManager != null)
                    {
                        ActionsNotifManager.Update(gameTime);
                    }
                    if (!isFinished)
                    {
                        //if (!waitForNextAction)
                        {
                            if (IsSaveStateToFile)
                            {
                                FilesHelperModule.SaveToStateFile(ListOfActions[nextActionIndex]);
                            }
                            Action currentAction = ListOfActions[nextActionIndex];
                            if (!(currentAction is VoidAction))
                            {
                                if (ActionsNotifManager != null)
                                {
                                    ActionsNotifManager.PushNextNotification();
                                }
                            }
                            if (IsSaveImage)
                            {
                                _shotsManager = _shotsManager ?? new EngineShotsManager();
                                _shotsManager.TakeEngineShot(false);
                            }

                            //if (!(currentAction is VoidAction))
                            //{
                            //    if (GenSimAgent.UpdateActionsIds.Count > actionId)
                            //    {
                            //        var res = GenSimAgent.UpdateActionsIds[actionId];
                            //        long uGen = res.UpdateId;
                            //        Action actionGen = res.Action;

                            //        long i = StaticData.UpdatesSoFar;
                            //        Action action = currentAction;
                            //    }
                            //}
                            actionId++;
                            CookiePosList.Add(StaticData.EngineManager.CookieRB.PositionXNA.ToString());
                            currentAction.ExcecuteAction();

                            if (RyseFreq)
                            {
                                actionFreq = RyseAgent.GetActionsFrequency(currentAction);
                            }
                            else
                            {
                                actionFreq = GenSimAgent.GetActionsFrequency(currentAction);
                            }
                            updateIdForNextAction = StaticData.UpdatesSoFar + actionFreq;
                            //waitForNextAction = true;
                        }
                        //else
                        //{
                        //if (StaticData.UpdatesSoFar == updateIdForNextAction)
                        {
                            //StaticData.UpdatesSoFar = 0;
                            //waitForNextAction = false;
                            if (nextActionIndex < ListOfActions.Count - 1)
                            {
                                nextActionIndex++;
                            }
                            else
                            {
                                isFinished = true;
                            }
                        }
                        //}
                    }
                    else
                    {
                        ActionsNotifManager = null;
                        //StaticData.EngineManager.Game1.TargetElapsedTime = TimeSpan.FromSeconds(1.0f/60.0f);
                    }
                }
            }
        }
Example #6
0
        public static void ExtractComponentToActionExperiment()
        {
            string       path = "100 Playability PPr.txt";
            StreamReader sr   = new StreamReader(path);
            StreamWriter sw   = new StreamWriter("ComponentToActionExperiment.txt");
            string       line = String.Empty;

            while ((line = sr.ReadLine()) != null)
            {
                String levelStr   = line.Split('\t')[12];
                String actionsStr = line.Split('\t')[13];

                LevelBuilder.CreateRestedLevel(levelStr, false);
                StaticData.GameSessionMode          = SessionMode.PlayingMode;
                ActionsExecuterGenSim.ListOfActions = new ActionsGenerator(actionsStr).Actions;
                ActionsExecuterGenSim.IsSimulatingGamePlayability = true;
                ActionsExecuterGenSim.nextActionIndex             = 0;
                ActionsExecuterGenSim.isFinished        = false;
                ActionsExecuterGenSim.IsSaveStateToFile = false;
                if (false)
                {
                    EngineShotsManager.ShowXNAWindow();
                }
                var gameTime = new GameTime();
                for (int i = 0; i < 1300; i++)
                {
                    ActionsExecuterGenSim.ManipulateActions(gameTime);
                    StaticData.EngineManager.Update(gameTime);
                }

                List <Component> items = new LevelGenerator(levelStr).Items;
                items.RemoveAt(0);
                items.RemoveAt(0);
                List <Action> actions      = ActionsExecuterGenSim.ListOfActions;
                int           nrOfNonVoids = actions.FindAll(a => !(a is VoidAction)).Count;
                actions = actions.FindAll(a => !(a is VoidAction)).ToList();

                RyseUsageManager usageManager = new RyseUsageManager(items, actions);
                StaticData.RyseComponentsUsageHelper = usageManager;
                usageManager.DoAnalysis();

                int nrOfBumps   = items.FindAll(item => (item is Bump)).Count;
                int nrOfRockets = items.FindAll(item => (item is Rocket)).Count;
                int nrOfRopes   = items.FindAll(item => (item is Rope)).Count;
                int nrOfBubbles = items.FindAll(item => (item is Bubble)).Count;
                int nrOfBlowers = items.FindAll(item => (item is Blower)).Count;

                int nrOfUsedComps = usageManager.UsedRopes
                                    + usageManager.UsedRocket
                                    + usageManager.UsedBlowers
                                    + usageManager.UsedBubbles
                                    + usageManager.UsedBumps;

                int    nrONonfUsedComps         = items.Count - nrOfUsedComps;
                double actionsToComponentsRatio = (nrOfUsedComps) / (double)items.Count;

                sw.WriteLine(items.Count
                             + "\t" + (nrOfNonVoids + usageManager.UsedBumps)
                             + "\t" + nrOfUsedComps
                             + "\t" + nrONonfUsedComps
                             + "\t" + actionsToComponentsRatio

                             + "\t" + usageManager.UsedRopes
                             + "\t" + usageManager.UsedRocket
                             + "\t" + usageManager.UsedBlowers
                             + "\t" + usageManager.UsedBubbles
                             + "\t" + usageManager.UsedBumps

                             + "\t" + nrOfRopes
                             + "\t" + nrOfRockets
                             + "\t" + nrOfBlowers
                             + "\t" + nrOfBubbles
                             + "\t" + nrOfBumps

                             + "\t" + usageManager.UsedRopes / (double)nrOfRopes
                             + "\t" + usageManager.UsedRocket / (double)nrOfRockets
                             + "\t" + usageManager.UsedBlowers / (double)nrOfBlowers
                             + "\t" + usageManager.UsedBubbles / (double)nrOfBubbles
                             + "\t" + usageManager.UsedBumps / (double)nrOfBumps);
                sw.Flush();
            }
            sr.Close();
        }