Exemple #1
0
        public override ExecutionResult Execute(SuperMetroidModel model, InGameState inGameState, int times = 1, bool usePreviousRoom = false)
        {
            IEnumerable <int> visitedNodeIds = inGameState.GetVisitedNodeIds(usePreviousRoom);

            // If the node at which we entered is not allowed, this is not fulfilled.
            if (!NodeIds.Contains(visitedNodeIds.First()))
            {
                return(null);
            }

            // If we have visited a node to avoid, this is not fulfilled.
            if (NodeIdsToAvoid.Intersect(visitedNodeIds).Any())
            {
                return(null);
            }

            // If we were supposed to stay put but have visited more than the starting node, this is not fulfilled
            if (MustStayPut && visitedNodeIds.Count() > 1)
            {
                return(null);
            }

            // If we have destroyed an obstacle that needed to be preserved, this is not fulfilled
            if (ObstaclesIdsToAvoid.Intersect(inGameState.GetDestroyedObstacleIds(usePreviousRoom)).Any())
            {
                return(null);
            }

            // We've avoided all pitfalls. This ResetRoom is fulfilled. Clone the InGameState to fulfill method contract
            return(new ExecutionResult(inGameState.Clone()));
        }
Exemple #2
0
        /// <summary>
        /// Returns whether the provided InGameState fulfills this PreviousNode element.
        /// </summary>
        /// <param name="inGameState">The in-game state to evaluate</param>
        /// <param name="usePreviousRoom">If true, uses the last known room state at the previous room instead of the current room to answer
        /// <returns></returns>
        public bool IsFulfilled(InGameState inGameState, bool usePreviousRoom)
        {
            // Look at second-to-last visited node (last node is the current node)
            IEnumerable <int> visitedNodeIds = inGameState.GetVisitedNodeIds(usePreviousRoom);

            return(visitedNodeIds.ElementAtOrDefault(visitedNodeIds.Count() - 2) == Value);
        }