Example #1
0
        public void StateSpaceToolsGetAllPossibleActionsTest()
        {
            Assert.AreEqual(1, StateSpaceTools.GetAllPossibleActions(testDomain, testProblem, testPlan, testState).Count);
            Plan  newPlan  = testPlan.Clone() as Plan;
            State newState = testPlan.Initial.Clone() as State;

            newPlan.Initial = newState.NewState(testPlan.Steps[0] as Operator, testProblem.Objects);
            newPlan.Steps.RemoveAt(0);
            newPlan.Initial.Table.Add(new Predicate("at", new List <ITerm> {
                new Term("hand", true), new Term("lake", true)
            }, true), true);
            List <StateSpaceEdge> actions = StateSpaceTools.GetAllPossibleActions(testDomain, testProblem, newPlan, newPlan.Initial as State);

            Assert.AreEqual(3, actions.Count);
        }
Example #2
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);
        }
Example #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)
 {
     // If it's the player's turn, return their list of actions.
     return(StateSpaceTools.GetAllPossibleActions(actor, node));
 }