Exemple #1
0
        public State GetSuccessorSuperposition(MediationTreeEdge edge)
        {
            VirtualMediationTreeNode parent = GetNode(edge.Parent) as VirtualMediationTreeNode;
            Superposition            pred   = parent.State as Superposition;
            Superposition            super  = new Superposition();

            if (edge is VirtualMediationTreeEdge)
            {
                VirtualMediationTreeEdge vEdge = edge as VirtualMediationTreeEdge;
                foreach (State state in pred.States)
                {
                    foreach (Operator action in vEdge.Actions)
                    {
                        if (state.Satisfies(action.Preconditions))
                        {
                            super.States.Add(state.NewState(action, data.problem.Objects));
                        }
                    }
                }
            }
            else
            {
                foreach (State state in pred.States)
                {
                    if (state.Satisfies(edge.Action.Preconditions))
                    {
                        super.States.Add(state.NewState(edge.Action as Operator, data.problem.Objects));
                    }
                }
            }

            return(super);
        }
Exemple #2
0
        // Checks if two predicates are equal.
        public override bool Equals(Object obj)
        {
            VirtualMediationTreeEdge edge = obj as VirtualMediationTreeEdge;

            if (edge.Actions.Count == Actions.Count)
            {
                foreach (Operator action in edge.Actions)
                {
                    if (!Actions.Contains(action))
                    {
                        return(false);
                    }
                }

                foreach (Operator action in Actions)
                {
                    if (!edge.Actions.Contains(action))
                    {
                        return(false);
                    }
                }

                if (parent != edge.Parent)
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Returns a list of outgoing edges for a given node.
        /// </summary>
        /// <param name="node">The node object.</param>
        /// <param name="actor">The name of the current actor.</param>
        /// <returns>A list of outgoing edges.</returns>
        public List <MediationTreeEdge> GetOutgoingEdges(MediationTreeNode node, string actor)
        {
            List <MediationTreeEdge> outgoing = StateSpaceTools.GetAllPossibleActions(actor, node);

            if (!data.superpositionManipulation)
            {
                return(outgoing);
            }

            List <MediationTreeEdge> unobservedActions = new List <MediationTreeEdge>();
            List <MediationTreeEdge> observedActions   = new List <MediationTreeEdge>();

            foreach (MediationTreeEdge edge in outgoing)
            {
                Superposition super = node.State as Superposition;
                bool          obs   = false;
                foreach (State state in super.States)
                {
                    if (state.Satisfies(edge.Action.Preconditions))
                    {
                        if (KnowledgeAnnotator.Observes(Player, edge.Action, state.Predicates))
                        {
                            observedActions.Add(edge);
                            obs = true;
                            break;
                        }
                    }
                }

                if (!obs)
                {
                    unobservedActions.Add(edge);
                }
            }

            if (unobservedActions.Count > 0)
            {
                VirtualMediationTreeEdge super = new VirtualMediationTreeEdge();
                foreach (MediationTreeEdge unobserved in unobservedActions)
                {
                    super.Actions.Add(unobserved.Action as Operator);
                }
                super.Parent = node.ID;
                observedActions.Add(super);
            }

            return(observedActions);
        }