public void CacheLeaves(Goal goal, Dictionary <string, float> worldStates, List <Action> actions, Dictionary <string, float> agentStates, bool simulate) { var planner = new Planner(); var leaves = planner.BuildLeaves(goal.Key, worldStates, actions, agentStates, out var success, simulate); if (leaves != null) { _goalLeaves[goal] = new List <Node>(leaves); } }
public void CachePlan(List <Goal> goals, List <Action> actions, Agent agent) { _goalActions.Clear(); _goalLeaves.Clear(); _goalErrors.Clear(); foreach (var goal in goals.OrderByDescending(x => x.Priority)) { var agentStates = new Dictionary <string, float>(); var worldStates = new Dictionary <string, float>(WorldStates); if (worldStates.ContainsKey(goal.Key)) { worldStates.Remove(goal.Key); } foreach (var worldState in worldStates.Reverse()) { if (WorldStatesVisibility[worldState.Key] == false) { worldStates.Remove(worldState.Key); } } var planner = new Planner(); var queuedActions = planner.Plan(agent, goal.Key, worldStates, actions, agentStates, _simulate); if (planner.ErrorRecords.ContainsKey(goal.Key)) { _goalErrors[goal] = planner.ErrorRecords[goal.Key]; } if (queuedActions != null) { _goalActions[goal] = new Queue <Action>(queuedActions); } planner = new Planner(); var leaves = planner.BuildLeaves(goal.Key, worldStates, actions, agentStates, out var success, _simulate); if (leaves != null) { _goalLeaves[goal] = new List <Node>(leaves); } } }