Exemplo n.º 1
0
 public IEnumerable <bool> DoBranch(ExplorationState state, IReadOnlyList <FlowEdge> edges)
 {
     foreach (var edge in edges)
     {
         yield return(true);
     }
 }
        public IEnumerable <bool> DoBranch(ExplorationState state, IReadOnlyList <FlowEdge> edges)
        {
            foreach (var edge in edges)
            {
                if (edge is OuterFlowEdge outerEdge)
                {
                    // What routine are we interested in
                    var routineGraph = outerEdge.From.Graph;

                    // Determine call/return balance of the given routine
                    int balance = (outerEdge.Kind == OuterFlowEdgeKind.MethodCall) ? 1 : -1;
                    foreach (var pathEdge in state.Path.Edges().OfType <OuterFlowEdge>())
                    {
                        if (pathEdge.To.Graph == routineGraph && pathEdge.Kind == OuterFlowEdgeKind.MethodCall)
                        {
                            balance++;
                        }
                        else if (pathEdge.From.Graph == routineGraph && pathEdge.Kind == OuterFlowEdgeKind.Return)
                        {
                            balance--;
                        }
                    }

                    // Do not let the actual call stack (its subset with this routine) height grow over the limit
                    yield return(Math.Abs(balance) <= this.RecursionLimit);
                }
                else if (edge.From.Flags.HasFlag(FlowNodeFlags.LoopBody))
                {
                    // TODO: Consider using subscribing to extensions and retractions instead
                    var loopCondNode = state.Path.Nodes().FirstOrDefault(n => n.Flags.HasFlag(FlowNodeFlags.LoopCondition));
                    if (loopCondNode == null)
                    {
                        yield return(true);
                    }
                    else
                    {
                        // LoopLimit enters from iterations + 1 enter from the code after the loop
                        int loopCount = state.Path.Nodes().Count(n => n == loopCondNode);
                        yield return(loopCount <= this.LoopLimit + 1);
                    }
                }
                else
                {
                    yield return(true);
                }
            }
        }
Exemplo n.º 3
0
        public GameController(Game game)
        {
            UI = new UserInterface(this);

            ElapsedTime = new Stopwatch();
            ElapsedTime.Start();
            Game = game;



            GameStates = new Dictionary <string, IGameState>();

            GameStates["Explore"]      = new ExplorationState(this);
            GameStates["PlayerQuit"]   = new PlayerQuitState(this);
            GameStates["StoryScene"]   = new StorySequenceState(this);
            GameStates["PlayerChoice"] = new PlayerChoiceState(this);
        }
Exemplo n.º 4
0
        private void SetState(ExplorationState newState)
        {
            switch (newState)
            {
            case ExplorationState.NOT_AVAILABLE:
                reset();
                setVisible(isVisible: false);
                setActive(isEnabled: false);
                internalState = newState;
                break;

            case ExplorationState.WAITING_TO_RESPAWN:
                reset();
                setVisible(isVisible: false);
                setActive(isEnabled: false);
                internalState = newState;
                break;

            case ExplorationState.READY_FOR_PICKUP:
                setVisible(isVisible: true);
                if (withinInfluenceRange)
                {
                    setActive(isEnabled: true);
                    if (ParticlesAppear != null)
                    {
                        Object.Instantiate(ParticlesAppear, base.gameObject.transform.position, Quaternion.identity);
                    }
                }
                internalState = newState;
                break;

            case ExplorationState.NONE:
                internalState = newState;
                break;

            default:
                internalState = ExplorationState.NONE;
                break;
            }
        }
Exemplo n.º 5
0
 public bool DoMerge(ExplorationState current, ExplorationState existing)
 {
     return(false);
 }
Exemplo n.º 6
0
 public bool DoExpectMerging(ExplorationState state)
 {
     return(false);
 }
Exemplo n.º 7
0
 public override bool DoSolve(ExplorationState state)
 {
     return(false);
 }
Exemplo n.º 8
0
 public override bool DoSolve(ExplorationState state)
 {
     return(state.Path.Node.IngoingEdges.Count > 1);
 }
Exemplo n.º 9
0
 public SmtSolverHandler SelectMergedSolverHandler(ExplorationState current, ExplorationState existing)
 {
     return(current.SolverHandler);
 }
Exemplo n.º 10
0
 public abstract bool DoSolve(ExplorationState state);
Exemplo n.º 11
0
 public override bool DoSolve(ExplorationState state)
 {
     return(state.Path.Depth % this.interval == 0);
 }