diff --git a/Aplib.Core.Tests/CombinatorTests.cs b/Aplib.Core.Tests/CombinatorTests.cs index 936accb3..675e635c 100644 --- a/Aplib.Core.Tests/CombinatorTests.cs +++ b/Aplib.Core.Tests/CombinatorTests.cs @@ -234,8 +234,8 @@ public void AnyOfTacticCombinator_WhenCalled_GivesExpectedTactic System.Predicate guard = _ => false; // Act - AnyOfTactic anyOfTactic = - AnyOf(metadata, guard, Primitive(action1, _ => true), Primitive(action2, _ => false)); + RandomTactic anyOfTactic = + Random(metadata, guard, Primitive(action1, _ => true), Primitive(action2, _ => false)); IAction? selectedAction = anyOfTactic.GetAction(It.IsAny()); @@ -254,8 +254,8 @@ public void AnyOfTacticCombinator_WithoutMetadata_GivesExpectedTactic() System.Predicate guard = _ => false; // Act - AnyOfTactic anyOfTactic = - AnyOf(guard, Primitive(action1, _ => true), Primitive(action2, _ => false)); + RandomTactic anyOfTactic = + Random(guard, Primitive(action1, _ => true), Primitive(action2, _ => false)); IAction? selectedAction = anyOfTactic.GetAction(It.IsAny()); @@ -274,8 +274,8 @@ public void AnyOfTacticCombinator_WithoutGuard_GivesExpectedTactic Action action2 = new(_ => { }); // Act - AnyOfTactic anyOfTactic = - AnyOf(metadata, Primitive(action1, _ => true), Primitive(action2, _ => false)); + RandomTactic anyOfTactic = + Random(metadata, Primitive(action1, _ => true), Primitive(action2, _ => false)); IAction? selectedAction = anyOfTactic.GetAction(It.IsAny()); @@ -292,7 +292,7 @@ public void AnyOfTacticCombinator_WithoutMetadataWithoutGuard_GivesExpectedTacti Action action2 = new(_ => { }); // Act - AnyOfTactic anyOfTactic = AnyOf(Primitive(action1, _ => true), Primitive(action2, _ => false)); + RandomTactic anyOfTactic = Random(Primitive(action1, _ => true), Primitive(action2, _ => false)); IAction? selectedAction = anyOfTactic.GetAction(It.IsAny()); diff --git a/Aplib.Core.Tests/Intent/Tactics/TacticTests.cs b/Aplib.Core.Tests/Intent/Tactics/TacticTests.cs index b9ee1852..5d233267 100644 --- a/Aplib.Core.Tests/Intent/Tactics/TacticTests.cs +++ b/Aplib.Core.Tests/Intent/Tactics/TacticTests.cs @@ -142,7 +142,7 @@ public void PrimitveTacticExecute_WhenGuardReturnsTrue_ActionIsSelected() public void AnyOfTactic_WithoutMetadata_ContainsDefaultMetadata() { // Act - AnyOfTactic tactic = new(_ => true); + RandomTactic tactic = new(_ => true); // Assert tactic.Metadata.Id.Should().NotBeEmpty(); @@ -151,7 +151,7 @@ public void AnyOfTactic_WithoutMetadata_ContainsDefaultMetadata() } /// - /// Given a parent of type with two subtactics, + /// Given a parent of type with two subtactics, /// When getting the next tactic, /// Then the result should be the action of an enabled tactic. /// @@ -163,7 +163,7 @@ public void AnyOfTacticGetAction_WhenASubtacticIsEnabled_ReturnsActionOfEnabledS Action action2 = new(_ => { }); PrimitiveTactic tactic1 = new(action1, _ => true); PrimitiveTactic tactic2 = new(action2, _ => false); - AnyOfTactic parentTactic = new(tactic1, tactic2); + RandomTactic parentTactic = new(tactic1, tactic2); // Act IAction? selectedAction = parentTactic.GetAction(It.IsAny()); @@ -178,7 +178,7 @@ public void AnyOfTactic_WithFalseGuard_ReturnsNoAction() // Arrange Action action = new(_ => { }); PrimitiveTactic tactic = new(action, _ => true); - AnyOfTactic parentTactic = new(_ => false, tactic); + RandomTactic parentTactic = new(_ => false, tactic); // Act IAction? selectedAction = parentTactic.GetAction(It.IsAny()); diff --git a/Aplib.Core.Tests/LoggableTests.cs b/Aplib.Core.Tests/LoggableTests.cs index 46ede76e..7fc08d28 100644 --- a/Aplib.Core.Tests/LoggableTests.cs +++ b/Aplib.Core.Tests/LoggableTests.cs @@ -50,7 +50,7 @@ public void PrimitiveTactic_WhenGettingTree_ReturnsCorrectTree() public void AnyOfTactic_WhenGettingTree_ReturnsCorrectTree() { // Arrange - AnyOfTactic tactic = new(_tactic1, _tactic2); + RandomTactic tactic = new(_tactic1, _tactic2); LogNode tactic1Node = new(_tactic1, 1, [new LogNode(_action1, 2)]); LogNode tactic2Node = new(_tactic2, 1, [new LogNode(_action2, 2)]); diff --git a/Aplib.Core/Combinators.cs b/Aplib.Core/Combinators.cs index cc490f7a..2a70c8e3 100644 --- a/Aplib.Core/Combinators.cs +++ b/Aplib.Core/Combinators.cs @@ -61,26 +61,26 @@ public static SequentialGoalStructure Seq(params IGoalSt #region Tactic combinators - /// - public static AnyOfTactic AnyOf + /// + public static RandomTactic Random (IMetadata metadata, System.Predicate guard, params ITactic[] subTactics) where TBeliefSet : IBeliefSet => new(metadata, guard, subTactics); - /// - public static AnyOfTactic AnyOf + /// + public static RandomTactic Random (System.Predicate guard, params ITactic[] subTactics) where TBeliefSet : IBeliefSet => new(guard, subTactics); - /// - public static AnyOfTactic AnyOf + /// + public static RandomTactic Random (IMetadata metadata, params ITactic[] subTactics) where TBeliefSet : IBeliefSet => new(metadata, subTactics); - /// - public static AnyOfTactic AnyOf(params ITactic[] subTactics) + /// + public static RandomTactic Random(params ITactic[] subTactics) where TBeliefSet : IBeliefSet => new(subTactics); diff --git a/Aplib.Core/Intent/Tactics/AnyOfTactic.cs b/Aplib.Core/Intent/Tactics/RandomTactic.cs similarity index 71% rename from Aplib.Core/Intent/Tactics/AnyOfTactic.cs rename to Aplib.Core/Intent/Tactics/RandomTactic.cs index 8db67a93..977f1cb7 100644 --- a/Aplib.Core/Intent/Tactics/AnyOfTactic.cs +++ b/Aplib.Core/Intent/Tactics/RandomTactic.cs @@ -7,9 +7,9 @@ namespace Aplib.Core.Intent.Tactics { /// - /// Represents a tactic that executes any of the provided subtactics. + /// Represents a tactic that executes a random tactic from the provided subtactics. /// - public class AnyOfTactic : Tactic + public class RandomTactic : Tactic where TBeliefSet : IBeliefSet { /// @@ -18,7 +18,7 @@ public class AnyOfTactic : Tactic protected internal readonly LinkedList> _subtactics; /// - /// Initializes a new instance of the class with the specified subtactics + /// Initializes a new instance of the class with the specified subtactics /// and an optional guard condition. /// /// @@ -26,7 +26,7 @@ public class AnyOfTactic : Tactic /// /// The guard condition. /// The list of subtactics. - public AnyOfTactic + public RandomTactic ( IMetadata metadata, System.Predicate guard, @@ -34,21 +34,21 @@ params ITactic[] subtactics ) : base(metadata, guard) => _subtactics = new LinkedList>(subtactics); - /// - public AnyOfTactic + /// + public RandomTactic (System.Predicate guard, params ITactic[] subtactics) : this(new Metadata(), guard, subtactics) { } - /// - public AnyOfTactic(IMetadata metadata, params ITactic[] subtactics) + /// + public RandomTactic(IMetadata metadata, params ITactic[] subtactics) : this(metadata, _ => true, subtactics) { } - /// - public AnyOfTactic(params ITactic[] subtactics) + /// + public RandomTactic(params ITactic[] subtactics) : this(new Metadata(), _ => true, subtactics) { }