示例#1
0
 internal void AddFluents(List <string> fluentsName)
 {
     foreach (var name  in fluentsName)
     {
         Fluent newFluent = new Fluent(name, false);
         Fluents.Add(newFluent);
     }
 }
 internal void AddFluents(List<string> fluentsName)
 {
     foreach (var name  in fluentsName)
     {
         Fluent newFluent = new Fluent(name, false);
         Fluents.Add(newFluent);
     }
 }
 public List<Fluent[]> CalculatePossibleFluents()
 {
     var result = new List<Fluent[]>();
     string[] fluentNames = this.GetFluentNames();
     int numberOfFluents = fluentNames.Length;
     foreach (var code in Gray.GetGreyCodesWithLengthN(numberOfFluents))
     {
         var possibleFluents = new Fluent[numberOfFluents];
         for (int i = 0; i < numberOfFluents; i++)
         {
             possibleFluents[i] = new Fluent { Name = fluentNames[i], Value = code[i] };
         }
         if (this.Evaluate(possibleFluents.Select(t => new Tuple<string, bool>(t.Name, t.Value))))
         {
             result.Add(possibleFluents);
         }
     }
     return result;
 }
        public void SetUp()
        {
            _idWorldAction = "idWorldAction";
            _startTime = 8;
            _durationTime = 5;

            _worldAction = new WorldAction(_idWorldAction, _startTime, _durationTime);

            _fluent = new Fluent()
            {
                Name = "a",
                Value = true
            };

            _state = new State
            {
                Fluents = new List<Fluent>{
                    new Fluent { Name = "a", Value = true },
                    new Fluent { Name = "b", Value = true },
                    new Fluent { Name = "c", Value = true },
                    new Fluent { Name = "d", Value = true }
                }
            };
        }
        public void SetUp()
        {
            _state = new State{
                Fluents = new List<Fluent>{
                    new Fluent { Name = "a", Value = true },
                    new Fluent { Name = "b", Value = true },
                    new Fluent { Name = "c", Value = true },
                    new Fluent { Name = "e", Value = true }
                }};

            var fluentC = new Fluent { Name = "c", Value = true };

            _worldDescription = new WorldDescription();

            // INITIALLY
            _worldDescription.Descriptions.Add(new Tuple<WorldDescriptionRecordType, WorldDescriptionRecord>(WorldDescriptionRecordType.Initially, new InitialRecord("a || b || c || e")));

            // ACTION CAUSES IF
            _worldDescription.Descriptions.Add(new Tuple<WorldDescriptionRecordType, WorldDescriptionRecord>(WorldDescriptionRecordType.ActionCausesIf, new ActionCausesIfRecord(action_A_2, "a && !b", "c")));
            _worldDescription.Descriptions.Add(new Tuple<WorldDescriptionRecordType, WorldDescriptionRecord>(WorldDescriptionRecordType.ActionCausesIf, new ActionCausesIfRecord(action_B_3, "a || b", "e")));
            _worldDescription.Descriptions.Add(new Tuple<WorldDescriptionRecordType, WorldDescriptionRecord>(WorldDescriptionRecordType.ActionCausesIf, new ActionCausesIfRecord(action_B_3, "!b && !c", "e")));

            // RELEASE FLUENT
            _worldDescription.Descriptions.Add(new Tuple<WorldDescriptionRecordType, WorldDescriptionRecord>(WorldDescriptionRecordType.ActionReleasesIf, new ActionReleasesIfRecord(action_B_3, fluentC, "e || c")));
        }
        private void ButtonAddFluent_Click(object sender, RoutedEventArgs e)
        {
            if (TextBoxFluents.Text == "")
            {
                LabelFluentsActionsValidation.Content = "Fluent name is required.";
                return;
            }
            if (!System.Text.RegularExpressions.Regex.IsMatch(TextBoxFluents.Text, @"[a-zA-Z]+[a-zA-Z0-9\-]*$"))
            {
                LabelFluentsActionsValidation.Content = "Fluent name should be alphanumeric.";
                return;
            }

            if (!Fluents.Contains(Fluents.FirstOrDefault(f => (f.Name == TextBoxFluents.Text))))
            {
                var f = new Fluent { Name = this.TextBoxFluents.Text };
                Fluents.Add(f);
                TextBoxFluents.Text = "";
                LabelFluentsActionsValidation.Content = "";
            }
            else
            {
                LabelFluentsActionsValidation.Content = "Fluent with this name already exists.";
            }
        }