public String GetPrefCompsToGrammarFile() { String strFinalGrammar = String.Empty; String compLevelBase = String.Empty; String compShouldPres = String.Empty; String compAlreadyPres = EngineStateManager.GetEngineStateFactStringWithSpaceDelimiterGEVAStyle(_comps); int compPresCounter = 0; if (!compAlreadyPres.Contains("frog")) { compShouldPres += "<frog>"; } if (!compAlreadyPres.Contains("rope")) { compShouldPres += "<rope>"; compPresCounter++; } if (!compAlreadyPres.Contains("blower")) { compShouldPres += "<blower>"; compPresCounter++; } if (!compAlreadyPres.Contains("rocket")) { compShouldPres += "<rocket>"; compPresCounter++; } if (!compAlreadyPres.Contains("bump")) { compShouldPres += "<bump>"; compPresCounter++; } if (!compAlreadyPres.Contains("bubble")) { compShouldPres += "<bubble>"; compPresCounter++; } if (compPresCounter < 5) { compLevelBase = "<level>::=<cookie><comps_design><comps>"; } else { compLevelBase = "<level>::=<cookie><comps_design>"; } strFinalGrammar = compLevelBase; strFinalGrammar += Environment.NewLine + @"<cookie>::=cookie(<x>,<y>) <frog>::=frog(<x>,<y>) <comps_design>::=" + compAlreadyPres + compShouldPres; strFinalGrammar += Environment.NewLine + GrammarRest; return(strFinalGrammar); }
private static IEnumerator WaitForSceneLoad(SceneRequest req, bool transitionOnSame) { var currScene = SceneManager.GetActiveScene().name; float waitOut = 0f; if (transitionOnSame || currScene != req.scene.sceneName) { var transition = req.scene.transitionIn == null ? defaultTransition : req.scene.transitionIn; CameraTransition.Fade(transition, out float waitIn, out waitOut); Log.Unity($"Performing fade transition for {waitIn}s before loading scene."); for (; waitIn > ETime.FRAME_YIELD; waitIn -= ETime.FRAME_TIME) { yield return(null); } } Log.Unity($"Scene loading for {req} started.", level: Log.Level.DEBUG3); StaticPreSceneUnloaded(); var op = SceneManager.LoadSceneAsync(req.scene.sceneName); while (!op.isDone) { yield return(null); } Log.Unity( $"Unity finished loading the new scene. Waiting for transition ({waitOut}s) before yielding control to player.", level: Log.Level.DEBUG3); req.onLoaded?.Invoke(); for (; waitOut > ETime.FRAME_YIELD; waitOut -= ETime.FRAME_TIME) { yield return(null); } req.onFinished?.Invoke(); EngineStateManager.SetLoading(false, () => LOADING = false); }
private void bSaveLevel_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StreamWriter sw = new StreamWriter(dialog.FileName, true); sw.WriteLine(EngineStateManager.GetEngineStateFactStringWithSpaceDelimiterGEVAStyle()); sw.Close(); } }
public static void SaveToStateFile(Action action) { StreamWriter sw = new StreamWriter(@"StatesFiles\" + Tester.FilesCounter + ".txt", true); sw.WriteLine(HelperModules.GenericHelperModule.GetActionsString(new List <Action>() { action }) + ";" + EngineStateManager.GetEngineStateFactStringWithSpaceDelimiterToStateFile() + ";" + CompsOfInterestProlog.GetCompsOfInterestFromProlog()); sw.Flush(); sw.Close(); }
private static void SetEngineStateIntoPredicatesFile() { String factsString = EngineStateManager.GetEngineStateFactStringWithEnterDelimiterToProlog(); StreamReader sR = new StreamReader(@"C:\CTREngine\ActionsOnlyPred.txt"); String actionsOnlyString = sR.ReadToEnd(); sR.Close(); StreamWriter sW = new StreamWriter(@"C:\CTREngine\CompsFinalPred.pl"); sW.WriteLine(factsString); sW.WriteLine(actionsOnlyString); sW.Close(); //Console.WriteLine(factsString); }
private static string GetCompsString(string[] positions) { List <Point> list = new List <Point>(); String strFinal = String.Empty; for (int i = 0; i < positions.Count(); i++) { if (positions[i] != String.Empty) { int x = Int32.Parse(positions[i].Split(',')[0].Trim()); int y = Int32.Parse(positions[i].Split(',')[1].Trim()); list.Add(new Point(x, y)); } } strFinal = EngineStateManager.GetEngineStateFactStringWithEnterDelimiterToProlog(list); return(strFinal); }
public static bool LoadScene(SceneRequest req) { if (!EngineStateManager.IsLoading && !LOADING) { Log.Unity($"Successfully requested scene load for {req}."); req.onQueued?.Invoke(); IsFirstScene = false; LOADING = true; EngineStateManager.SetLoading(true, null); SceneLoader.Main.RunRIEnumerator(WaitForSceneLoad(req, true)); return(true); } else { Log.Unity($"REJECTED scene load for {req}."); } return(false); }
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(); } }
//public static RYSEManager SimulatePlayabiltityFromDesigner(bool isSaveImage) //{ // RYSEManager manager = new RYSEManager(10); // manager.IsSaveImage = isSaveImage; // manager.Simulator = new PlayabilitySimulatorEngineProlog(manager.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 node = new ActionNode(new VoidAction()); // manager.SimulatePlayability(node, StaticData.EngineManager, ref playability, 0, performedActions, performedVel, 0, PlayabilityCheckMode.NormalCheck); // DateTime d2 = DateTime.Now; // manager.totalTime = (int)(d2 - d1).TotalSeconds; // //if (playability == true) // //{ // // MessageBox.Show("Playable! " + this.Simulator.ClosestCookieFrogDistance); // //} // if (playability) // { // MessageBox.Show("The level is Playable!" + Environment.NewLine // + "Finished processing in = " + manager.totalTime.ToString() + " sec." + Environment.NewLine // + "Nodes explored = " + manager.nodesExplored + Environment.NewLine // + "Nr of tree cuts = " + manager.NrOfTerminates + Environment.NewLine // + "Solution tree depth = " + performedActions.Count + Environment.NewLine // + "Best distance = " + manager.Simulator.ClosestCookieFrogDistance); // LivePlayabilitySimulator liveSim = new LivePlayabilitySimulator(engine); // liveSim.SimulateSameWindow(performedActions); // } // else // { // MessageBox.Show(@"Can't find a solution for this level."); // } // //StaticData.EngineManager.Game1 = DesignerManager.Game; // return manager; //} //public static RYSEManager SimulatePlayabiltityFromDesigner(bool isSaveImage) //{ // String gevaStr = EngineStateManager.GetEngineStateFactStringWithSpaceDelimiterGEVAStyle(); // //LevelBuilder.CreateRestedLevel(gevaStr, false); // RYSEManager manager = new RYSEManager(10); // manager.Simulator = new PlayabilitySimulatorEngineProlog(false); // manager.IsSaveImage = false; // StaticData.GameSessionMode = SessionMode.PlayingMode; // bool playability = false; // List<Action> performedActions = new List<Action>(); // List<Vector3> performedVel = new List<Vector3>(); // DateTime d1 = DateTime.Now; // ActionNode baseNode = new ActionNode(new VoidAction()); // manager.SimulatePlayability(baseNode, StaticData.EngineManager, ref playability, 0, performedActions, performedVel, 0, PlayabilityCheckMode.NormalCheck); // DateTime d2 = DateTime.Now; // manager.totalTime = (int)(d2 - d1).TotalSeconds; // FilesHelperModule.PrintTreeToFile(baseNode); // FilesHelperModule.DeepCopyTreeToFile(baseNode); // if (playability) // { // MessageBox.Show("The level is Playable!" + Environment.NewLine // + "Finished processing in = " + manager.totalTime.ToString() + " sec." + Environment.NewLine // + "Nodes explored = " + manager.nodesExplored + Environment.NewLine // + "Nr of tree cuts = " + manager.NrOfTerminates + Environment.NewLine // + "Solution tree depth = " + performedActions.Count + Environment.NewLine // + "Best distance = " + manager.Simulator.ClosestCookieFrogDistance); // StaticData.EngineManager.Game1 = DesignerManager.Game; // LevelBuilder.CreateRestedLevel(gevaStr, false); // FilesHelperModule.PrintTreeToFile(baseNode, StaticData.EngineManager, performedActions); // StaticData.GameSessionMode = SessionMode.PlayingMode; // LivePlayabilitySimulator simulator = new LivePlayabilitySimulator(StaticData.EngineManager); // simulator.SimulateSameWindow(performedActions); // } // else // { // MessageBox.Show(@"Can't find a solution for this level."); // } // StaticData.EngineManager.Game1 = DesignerManager.Game; // return manager; //} public static void SimulatePlayabiltityFromDesigner() { var strGeva = EngineStateManager.GetEngineStateFactStringWithSpaceDelimiterGEVAStyle(); StreamWriter sw = new StreamWriter(@"C:\CTREngine\LevelToPlayCheckDesigner.txt"); sw.WriteLine(strGeva); sw.Close(); //System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo(); //proc.FileName = @"C:\CTREngine\CRUSTEngine_PlayabilityChecker.exe"; //proc.Arguments = "0" + " " + @strGeva; //proc.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //System.Diagnostics.Process.Start(proc); var process = new Process(); process.EnableRaisingEvents = false; process.StartInfo.FileName = @"C:\CTREngine\CRUSTEngine_PlayabilityChecker_ToDesigner.exe"; process.StartInfo.Arguments = ""; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.Start(); process.WaitForExit(); process.Close(); StreamReader sr = new StreamReader(@"C:\CTREngine\PhysicsEngine_EvolvePlayActions.txt"); String line = sr.ReadToEnd(); DesignEnhanceManager.GevaLevel = line.Split('\t')[13]; DesignEnhanceManager.PlayabilityActions = line.Split('\t')[14]; if (line.Split('\t')[1].ToLower() == "true") { MessageBox.Show( @"Playability-check is finished. The engine has found a playable level."); } else { MessageBox.Show( @"Playability-check is finished. The engine hasn't found a playable level."); } sr.Close(); }
protected override void Awake() { MainScreen = new UIScreen( new FuncNode(() => { if (GameManagement.Instance.TryContinue()) { EngineStateManager.AnimatedUnpause(); return(true); } else { return(false); } }, () => death_continue_ls(GameManagement.Instance.Continues), true), new ConfirmFuncNode(GameManagement.Restart, restart, true) .EnabledIf(() => GameManagement.CanRestart), new ConfirmFuncNode(GameManagement.GoToMainMenu, to_menu, true) ).With(UIScreen); MainScreen.ExitNode = MainScreen.top[0]; base.Awake(); }
//"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); } } } }