public void StateSpaceToolsGetPlayerActionsCountUpdatePlanTest() { 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); List <Operator> actions = StateSpaceTools.GetPlayerActions(testDomain, testProblem, newPlan.Initial as State); Assert.AreEqual(2, actions.Count); }
public void StateSpaceToolsGetPossibleActionsTest() { Assert.AreEqual(1, StateSpaceTools.GetPossibleActions(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); List <StateSpaceEdge> actions = StateSpaceTools.GetPossibleActions(testDomain, testProblem, newPlan, newPlan.Initial as State); Assert.AreEqual(2, actions.Count); }
/// <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 <GameTreeEdge> GetOutgoingEdges(GameTreeNode node, string actor) { // Initialize the list of outgoing edges. List <GameTreeEdge> outgoing = new List <GameTreeEdge>(); // Iterate through the actions enabled for the input actor in the current node's state. foreach (Operator action in StateSpaceTools.GetActions(actor, node.Domain, node.Problem, node.State)) { // Add an outgoing edge for each of these actions to the list. outgoing.Add(new GameTreeEdge(action, node.ID)); } // Return the list of outgoing edges. return(outgoing); }
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); }
/// <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); }
public void StateSpaceToolsGetPlayerActionsTest() { List <Operator> testPlayerActions = new List <Operator> { new Operator ( new Predicate("move", new List <ITerm> { new Term("arthur", true), new Term("woods", true), new Term("lake", true) }, true), new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("woods", true) }, true), new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("lake", true) }, false), new Predicate("character", new List <ITerm> { new Term("arthur", true) }, true), new Predicate("alive", new List <ITerm> { new Term("arthur", true) }, true), new Predicate("location", new List <ITerm> { new Term("woods", true) }, true), new Predicate("location", new List <ITerm> { new Term("lake", true) }, true), new Predicate("connected", new List <ITerm> { new Term("lake", true), new Term("woods", true) }, true), }, new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("woods", true) }, false), new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("lake", true) }, true), } ) }; List <Operator> computedPlayerActions = StateSpaceTools.GetPlayerActions(testDomain, testProblem, testState); Assert.AreEqual(testPlayerActions[0], computedPlayerActions[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)); }
public void StateSpaceToolsGetAllPossibleSamActionsTest() { Assert.AreEqual(1, StateSpaceTools.GetActions("sam", testDomain, testProblem, testState).Count); }
public void StateSpaceToolsGetLaterConstituentActionTest() { Plan newPlan = testPlan.Clone() as Plan; newPlan.Steps = new List <IOperator> { new Operator ( new Predicate("move", new List <ITerm> { new Term("sam", true), new Term("woods", true), new Term("lake", true) }, true), new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("sam", true), new Term("woods", true) }, true), new Predicate("at", new List <ITerm> { new Term("sam", true), new Term("lake", true) }, false), new Predicate("character", new List <ITerm> { new Term("sam", true) }, true), new Predicate("alive", new List <ITerm> { new Term("sam", true) }, true), new Predicate("location", new List <ITerm> { new Term("woods", true) }, true), new Predicate("location", new List <ITerm> { new Term("lake", true) }, true), new Predicate("connected", new List <ITerm> { new Term("lake", true), new Term("woods", true) }, true), }, new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("sam", true), new Term("woods", true) }, false), new Predicate("at", new List <ITerm> { new Term("sam", true), new Term("lake", true) }, true), } ), new Operator ( new Predicate("move", new List <ITerm> { new Term("arthur", true), new Term("woods", true), new Term("lake", true) }, true), new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("woods", true) }, true), new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("lake", true) }, false), new Predicate("character", new List <ITerm> { new Term("arthur", true) }, true), new Predicate("alive", new List <ITerm> { new Term("arthur", true) }, true), new Predicate("location", new List <ITerm> { new Term("woods", true) }, true), new Predicate("location", new List <ITerm> { new Term("lake", true) }, true), new Predicate("connected", new List <ITerm> { new Term("lake", true), new Term("woods", true) }, true), }, new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("woods", true) }, false), new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("lake", true) }, true), } ), new Operator ( new Predicate("take", new List <ITerm> { new Term("arthur", true), new Term("excalibur", true), new Term("lake", true) }, true), new List <IPredicate> { new Predicate("character", new List <ITerm> { new Term("arthur", true) }, true), new Predicate("character", new List <ITerm> { new Term("excalibur", true) }, false), new Predicate("alive", new List <ITerm> { new Term("arthur", true) }, true), new Predicate("at", new List <ITerm> { new Term("arthur", true), new Term("lake", true) }, true), new Predicate("at", new List <ITerm> { new Term("excalibur", true), new Term("lake", true) }, true), }, new List <IPredicate> { new Predicate("at", new List <ITerm> { new Term("excalibur", true), new Term("lake", true) }, false), new Predicate("has", new List <ITerm> { new Term("arthur", true), new Term("excalibur", true) }, true), } ) }; Assert.AreEqual("move", StateSpaceTools.GetConstituentAction(testDomain, testProblem, newPlan, testState).Action.Name); }
public void StateSpaceToolsGetConstituentActionTest() { string constituentActionName = StateSpaceTools.GetConstituentAction(testDomain, testProblem, testPlan, testState).Action.Name; Assert.AreEqual("move", constituentActionName); }
public void StateSpaceToolsGetSpanningLinksCountTest() { Assert.AreEqual(11, StateSpaceTools.GetSpanningLinks(testPlan).Count); }
public void StateSpaceToolsGetAllPlayerActionsCountTest() { Assert.AreEqual(72, StateSpaceTools.GetAllActions(testProblem.Player.ToLower(), testDomain, testProblem).Count); }