Beispiel #1
0
 private void SetNodeActionDetails()
 {
     g     = parent.g + action.Cost;
     state = parent.state.Clone();
     state.ClearMetPreconditions(action.GetEffects());
     state.AddUnmetPreconditions(action.GetPreconditions());
     h = GetNumUnmetPreconditions();
 }
Beispiel #2
0
        private VisualElement GetActionDetails(IAIAction <L, V> action)
        {
            var actionContainer = new VisualElement();

            actionContainer.AddToClassList("action");

            var title = new Button {
                text = action.ToString()
            };

            title.AddToClassList("action-title");
            actionContainer.Add(title);

            title.clicked += () => {
                if (expandedActions.Contains(action))
                {
                    expandedActions.Remove(action);
                }
                else
                {
                    expandedActions.Add(action);
                }
                UpdateContents();
            };

            if (expandedActions.Contains(action))
            {
                var componentsSuccess = action.CheckComponents();
                actionContainer.Add(new Label(componentsSuccess ? "Has Components" : "Components check failed"));

                var actionDetails = new VisualElement();
                actionDetails.AddToClassList("action-details");

                var preconditions = action.GetPreconditions();
                var effects       = action.GetEffects();

                var preconditionsContainer = GetConditionContainer("Preconditions", preconditions);
                actionDetails.Add(preconditionsContainer);

                var effectsContainer = GetConditionContainer("Effects", effects);
                actionDetails.Add(effectsContainer);

                actionContainer.Add(actionDetails);
            }

            return(actionContainer);
        }