Ejemplo n.º 1
0
        public static int GetActionsFrequency(Action action)
        {
            int newTimeStep = 15;

            switch (action.AType)
            {
            case ActionType.BlowerPress:
                newTimeStep = 15;
                break;

            case ActionType.RopeCut:
                newTimeStep = 10;
                break;

            case ActionType.VoidAction:
                newTimeStep = 12;
                break;

            case ActionType.BubblePinch:
                newTimeStep = 15;
                break;

            case ActionType.RocketPress:
                newTimeStep = 17;
                break;

            default:
                newTimeStep = 15;
                break;
            }
            return(newTimeStep);
        }
Ejemplo n.º 2
0
        private TextureType GetNotifAction(Action action)
        {
            switch (action.AType)
            {
            case ActionType.BlowerPress:
                return(TextureType.BlowerPressNotif);

                break;

            case ActionType.RopeCut:
                return(TextureType.RopeCutNotif);

                break;

            //case ActionType.VoidAction:
            //    return TextureType.VoidActionNotif;
            //    break;
            case ActionType.BubblePinch:
                return(TextureType.BubblePinchNotif);

                break;

            case ActionType.TerminateBranch:
                break;

            case ActionType.RocketPress:
                return(TextureType.RocketPressNotif);

                break;

            default:
                return(TextureType.VoidActionNotif);
            }
            return(TextureType.VoidActionNotif);
        }
Ejemplo n.º 3
0
        public static List <Action> ConvertToActions(String pheno)
        {
            List <Action> actions = new List <Action>();

            String[] pStringArr = pheno.Trim().Split(')');
            pStringArr = StringHelper.GetPropperPhenoArrWithTerminals(pStringArr);
            for (int i = 0; i < pStringArr.Length; i++)
            {
                try
                {
                    Action action     = null;
                    String currentCmp = pStringArr[i].Trim();
                    if (!currentCmp.Contains("("))
                    {
                        action = GetNewAction(currentCmp, null);
                    }
                    else
                    {
                        String   cmpName = currentCmp.Split('(')[0].Trim();
                        String[] pars    = currentCmp.Split('(')[1].Trim().Split(',');
                        action = GetNewAction(cmpName, pars);
                    }
                    if (action != null)
                    {
                        actions.Add(action);
                    }
                }
                catch (Exception)
                { }
            }
            return(actions);
        }
Ejemplo n.º 4
0
 public ActionsGenerator(Action action)
 {
     this.Actions = new List <Action>()
     {
         action
     };
 }
Ejemplo n.º 5
0
        private void ExecuteAction(Action nextAction)
        {
            long sss = StaticData.UpdatesSoFar;

            UpdateActionsIds.Add(new UpdateActionPair(StaticData.UpdatesSoFar, nextAction));
            Actions.Add(nextAction);
            Simulator.ActionsFrequency = GenSimAgent.GetActionsFrequency(nextAction);
            Simulator.RunEngine(new ActionsGenerator(nextAction));
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        private bool IsActionOnComponent(Component component, Action action)
        {
            switch (action.AType)
            {
            case ActionType.BlowerPress:
            {
                Blower        item    = ((Blower)component);
                BlowerService service = ((BlowerPress)action).BlowerPressed;
                return(item.X == service.PositionXNA.X && item.Y == service.PositionXNA.Y);
            }
            break;

            case ActionType.RopeCut:
            {
                Rope          item    = ((Rope)component);
                SpringService service = ((RopeCut)action).RopeBeingCut;
                return(item.X == service.Masses[0].PositionXNA.X && item.Y == service.Masses[0].PositionXNA.Y);
            }
            break;

            case ActionType.VoidAction:
                break;

            case ActionType.BubblePinch:
            {
                Bubble        item    = ((Bubble)component);
                BubbleService service = ((BubblePinch)action).BubblePinched;
                return(item.X == service.PositionXNAInitial.X && item.Y == service.PositionXNAInitial.Y);
            }
            break;

            case ActionType.TerminateBranch:
                break;

            case ActionType.RocketPress:
            {
                Rocket item = ((Rocket)component);
                RocketCarrierService service = ((RocketPress)action).RocketPressed;
                return(item.X == service.PositionXNAInitial.X && item.Y == service.PositionXNAInitial.Y);
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(false);
        }
Ejemplo n.º 8
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);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public UpdateActionPair(long updatesSoFar, Action nextAction)
 {
     this.UpdateId = updatesSoFar;
     this.Action   = nextAction;
 }
Ejemplo n.º 10
0
        public static int GetActionsFrequency(Action action)
        {
            int newTimeStep = 1;

            return(newTimeStep);
        }