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); } } } }
public static void GenerateGevaLevelEvolvePlayabilityFF(String[] args, bool isPrintPositionOnly, bool isSaveImage, int voidInitPlayTotalCount) { StaticData.EngineManager = null; LevelBuilder.CreateRestedLevel(args[1], true); var engineInit = StaticData.EngineManager; 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); List <Action> performedActions = new List <Action>(); List <Vector3> performedVel = new List <Vector3>(); double closestDistSoFar = Double.MaxValue; performedActions = new List <Action>(); StaticData.EngineManager = engine; DateTime d1 = DateTime.Now; ActionNode baseNode = new ActionNode(new VoidAction()); agent.SimulatePlayability(baseNode, StaticData.EngineManager, ref playability, 0, performedActions, performedVel, 0, PlayabilityCheckMode.NormalCheck); DateTime d2 = DateTime.Now; FilesHelperModule.DeepCopyTreeToFile(baseNode); FilesHelperModule.PrintTreeToFile(baseNode, engineInit, performedActions); agent.totalTime = (int)((d2 - d1).TotalSeconds); if (agent.bestClosestFrogCookieDist < closestDistSoFar) { closestDistSoFar = agent.bestClosestFrogCookieDist; } //if (performedActions.Count <= 3) //{ // closestDistSoFar = 70; //} if (closestDistSoFar > 1000) { closestDistSoFar = 1000; } 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 = "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" + 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"); sw.WriteLine(strFile); sw.Flush(); sw.Close(); } else { StreamWriter sw = new StreamWriter(@"C:\CTREngine\PhysicsEngine_EvolvePlayActionsNonPlayable.txt"); sw.WriteLine(strFile); sw.Flush(); sw.Close(); } { StreamWriter sw = new StreamWriter(@"C:\CTREngine\PhysicsEngine_EvolvePlayActionsAllLevels.txt", true); sw.WriteLine(strFile); sw.Flush(); sw.Close(); } }