public void Test30() { //Step 1: Construct any Pipeline MainViewModel mvm = MainViewModelTest.GetInstance(); ColorInputNode colorInput = new ColorInputNode(); mvm.Model.Graph.AddNode(colorInput); InverterNode inverter = new InverterNode(); mvm.Model.Graph.AddNode(inverter); mvm.Model.Graph.AddEdge(colorInput.Outputs[0], inverter.Inputs[0]); Assert.Contains(colorInput, mvm.Model.Graph.Nodes); Assert.Contains(inverter, mvm.Model.Graph.Nodes); Assert.Equal(colorInput.Outputs[0], inverter.Inputs[0].Source); //Step 2: Save Pipeline using (var stream = File.Create(@"..\..\..\..\output\test30.yuvka")) new NetDataContractSerializer().Serialize(stream, mvm.Model); Assert.True(File.Exists(@"..\..\..\..\output\test30.yuvka")); //Step 3: Clear Pipeline mvm.Clear(); Assert.Empty(mvm.Model.Graph.Nodes); //Step 4: Reload Pipeline using (var stream = File.OpenRead(@"..\..\..\..\output\test30.yuvka")) mvm.Model = (PipelineState)new NetDataContractSerializer().Deserialize(stream); Assert.True(mvm.Model.Graph.Nodes[0] is ColorInputNode); Assert.True(mvm.Model.Graph.Nodes[1] is InverterNode); Assert.Equal(mvm.Model.Graph.Nodes[0].Outputs[0], mvm.Model.Graph.Nodes[1].Inputs[0].Source); }
public void Test30() { //Step 1: Construct any Pipeline MainViewModel mvm = MainViewModelTest.GetInstance(); ColorInputNode colorInput = new ColorInputNode(); mvm.Model.Graph.AddNode(colorInput); InverterNode inverter = new InverterNode(); mvm.Model.Graph.AddNode(inverter); mvm.Model.Graph.AddEdge(colorInput.Outputs[0], inverter.Inputs[0]); Assert.Contains(colorInput, mvm.Model.Graph.Nodes); Assert.Contains(inverter, mvm.Model.Graph.Nodes); Assert.Equal(colorInput.Outputs[0], inverter.Inputs[0].Source); //Step 2: Save Pipeline using (var stream = File.Create(@"..\..\..\..\output\test30.yuvka")) new NetDataContractSerializer().Serialize(stream, mvm.Model); Assert.True(File.Exists(@"..\..\..\..\output\test30.yuvka")); //Step 3: Clear Pipeline mvm.Clear(); Assert.Empty(mvm.Model.Graph.Nodes); //Step 4: Reload Pipeline using (var stream = File.OpenRead(@"..\..\..\..\output\test30.yuvka")) mvm.Model = (PipelineState) new NetDataContractSerializer().Deserialize(stream); Assert.True(mvm.Model.Graph.Nodes[0] is ColorInputNode); Assert.True(mvm.Model.Graph.Nodes[1] is InverterNode); Assert.Equal(mvm.Model.Graph.Nodes[0].Outputs[0], mvm.Model.Graph.Nodes[1].Inputs[0].Source); }
public void RunningChildReturnsRunning() { var child = new ReturnXNode(NodeStatus.RUNNING); var node = new InverterNode(child); var status = node.Tick(); Assert.That(status, Is.EqualTo(NodeStatus.RUNNING)); }
public void WithoutDecoratedNode() { var invert = new InverterNode <int, int>(); Assert.Throws <BehaviourTreeException>(() => { invert.Compile(); }); }
public void SuccessChildReturnsFailure() { var child = new AlwaysSuccessNode(); var inverterNode = new InverterNode(child); var status = inverterNode.Tick(); Assert.That(status, Is.EqualTo(NodeStatus.FAILURE)); }
public void FailureChildReturnsSuccess() { var child = new AlwaysFailureNode(); var inverterNode = new InverterNode(child); var status = inverterNode.Tick(); Assert.That(status, Is.EqualTo(NodeStatus.SUCCESS)); }
public static BehaviourTreeNodeSequenceBuilder <TTickData, TState> Inverter <TTickData, TState>( this BehaviourTreeNodeSequenceBuilder <TTickData, TState> builder, string name, Action <BehaviourTreeNodeDecoratorBuilder <TTickData, TState> > config) { var newNode = new InverterNode <TTickData, TState>(name); return(builder.Add(newNode, config)); }
public void Tick_ChildFailure_ReturnsSuccess() { var blackboard = this.GetBlackboard(); var childStub = new Mock <ActionNode <TestBlackboard> >(); var inverterNode = new InverterNode <TestBlackboard>(childStub.Object); childStub.Setup(x => x.Tick(blackboard)).Returns(NodeStatus.Failure); Assert.AreEqual(NodeStatus.Success, inverterNode.Tick(blackboard)); }
public static BehaviourTreeNodeRandomBuilder <TTickData, TState> Inverter <TTickData, TState>( this BehaviourTreeNodeRandomBuilder <TTickData, TState> builder, string name, uint probability, Action <BehaviourTreeNodeDecoratorBuilder <TTickData, TState> > config) { var newNode = new InverterNode <TTickData, TState>(name); return(builder.Add(probability, newNode, config)); }
public static void Inverter <TTickData, TState> (this BehaviourTreeNodeDecoratorBuilder <TTickData, TState> builder, string name, Action <BehaviourTreeNodeDecoratorBuilder <TTickData, TState> > config ) { var newNode = new InverterNode <TTickData, TState>(name); builder.Decorate(newNode, config); }
public void ExecutionResult(IBehaviourTreeNode <int, int> node, BehaviourTreeState expectedState) { var invert = new InverterNode <int, int>(); invert.Decorate(node); var func = invert.Compile(); var state = func(0, 0); Assert.Equal(expectedState, state); }
public void AddMoreThatOneNode() { var invert = new InverterNode <int, int>(); var mockNode = new Mock <IBehaviourTreeNode <int, int> >(); Assert.Throws <BehaviourTreeException>(() => { invert.Decorate(mockNode.Object); invert.Decorate(mockNode.Object); }); }
public void GlobalTest10() { MainViewModel mvm = MainViewModelTest.GetInstance(); PipelineViewModel pvm = mvm.PipelineViewModel; // Step 1: The user clicks "New" to create a new pipeline mvm.Clear(); Assert.Empty(mvm.Model.Graph.Nodes); var mock = new Mock <IDragEventInfo>(); // Step 2: Create each type of node once by drag-and-drop VideoInputNode vin = (VideoInputNode)AddNode <VideoInputNode>(pvm, mock, new Point(10, 30)); AdditiveMergeNode amn = (AdditiveMergeNode)AddNode <AdditiveMergeNode>(pvm, mock, new Point(30, 30)); BlurNode bn = (BlurNode)AddNode <BlurNode>(pvm, mock, new Point(50, 30)); BrightnessContrastSaturationNode bcsn = (BrightnessContrastSaturationNode)AddNode <BrightnessContrastSaturationNode>(pvm, mock, new Point(70, 30)); ColorInputNode cin = (ColorInputNode)AddNode <ColorInputNode>(pvm, mock, new Point(10, 50)); DelayNode dln = (DelayNode)AddNode <DelayNode>(pvm, mock, new Point(90, 30)); DiagramNode dgn = (DiagramNode)AddNode <DiagramNode>(pvm, mock, new Point(110, 30)); DifferenceNode dfn = (DifferenceNode)AddNode <DifferenceNode>(pvm, mock, new Point(30, 50)); HistogramNode hn = (HistogramNode)AddNode <HistogramNode>(pvm, mock, new Point(50, 50)); ImageInputNode imin = (ImageInputNode)AddNode <ImageInputNode>(pvm, mock, new Point(70, 50)); InverterNode invn = (InverterNode)AddNode <InverterNode>(pvm, mock, new Point(90, 50)); NoiseInputNode nin = (NoiseInputNode)AddNode <NoiseInputNode>(pvm, mock, new Point(110, 50)); OverlayNode on = (OverlayNode)AddNode <OverlayNode>(pvm, mock, new Point(10, 70)); RgbSplitNode rgbsn = (RgbSplitNode)AddNode <RgbSplitNode>(pvm, mock, new Point(30, 70)); WeightedAveragedMergeNode wamn = (WeightedAveragedMergeNode)AddNode <WeightedAveragedMergeNode>(pvm, mock, new Point(50, 70)); // Step 3: Create the edges mvm.Model.Graph.AddEdge(vin.Outputs[0], bn.Inputs[0]); Assert.Equal(vin.Outputs[0], bn.Inputs[0].Source); amn.Inputs.Add(new Node.Input()); mvm.Model.Graph.AddEdge(vin.Outputs[0], amn.Inputs[0]); Assert.Equal(vin.Outputs[0], amn.Inputs[0].Source); mvm.Model.Graph.AddEdge(bn.Outputs[0], dln.Inputs[0]); Assert.Equal(bn.Outputs[0], dln.Inputs[0].Source); mvm.Model.Graph.AddEdge(dln.Outputs[0], dfn.Inputs[0]); Assert.Equal(dln.Outputs[0], dfn.Inputs[0].Source); mvm.Model.Graph.AddEdge(imin.Outputs[0], dfn.Inputs[1]); Assert.Equal(imin.Outputs[0], dfn.Inputs[1].Source); mvm.Model.Graph.AddEdge(dfn.Outputs[0], invn.Inputs[0]); Assert.Equal(dfn.Outputs[0], invn.Inputs[0].Source); mvm.Model.Graph.AddEdge(invn.Outputs[0], on.Inputs[0]); Assert.Equal(invn.Outputs[0], on.Inputs[0].Source); mvm.Model.Graph.AddEdge(vin.Outputs[0], on.Inputs[1]); Assert.Equal(vin.Outputs[0], on.Inputs[1].Source); mvm.Model.Graph.AddEdge(vin.Outputs[0], rgbsn.Inputs[0]); Assert.Equal(vin.Outputs[0], rgbsn.Inputs[0].Source); mvm.Model.Graph.AddEdge(rgbsn.Outputs[2], hn.Inputs[0]); Assert.Equal(rgbsn.Outputs[2], hn.Inputs[0].Source); }
void SetUpBehaviorTree() { SequenceNode rootSequence = new SequenceNode("Root"); behaviorTree.AddRoot(rootSequence); InverterNode isDeadInverter = new InverterNode(); rootSequence.AddChild(isDeadInverter); ConditionalNode isDead = new DeathCondition <Miner>(this); isDeadInverter.AddChild(isDead); SelectorNode mainSelector = new SelectorNode("Main"); rootSequence.AddChild(mainSelector); SequenceNode miningSequence = new SequenceNode("Mining"); mainSelector.AddChild(miningSequence); SequenceNode depositingSequence = new SequenceNode("Depositing"); mainSelector.AddChild(depositingSequence); InverterNode isBagFullInverter = new InverterNode(); miningSequence.AddChild(isBagFullInverter); ConditionalNode isBagFull = new BagFullCondition <Miner>(this); isBagFullInverter.AddChild(isBagFull); LeafNode walkToMine = new WalkToAction <Miner>(this, targetMiningPoint.position, targetMiningPoint.gameObject.name); miningSequence.AddChild(walkToMine); LeafNode mine = new MineAction <Miner>(this, mineIntervals, resourceMinedPerInterval); miningSequence.AddChild(mine); LeafNode walkToBase = new WalkToAction <Miner>(this, targetDeployPoint.position, targetDeployPoint.gameObject.name); depositingSequence.AddChild(walkToBase); LeafNode deposit = new DepositAction <Miner>(this, depositDuration); depositingSequence.AddChild(deposit); }
/// <summary> /// Create an inverter node that inverts the success/failure of its children. /// </summary> public BehaviourTreeBuilder Inverter() { AssertCanModify(); var name = _idGenerator.GetId(typeof(InverterNode)); var inverterNode = new InverterNode(name); if (_parentNodeStack.Count > 0) { _parentNodeStack.Peek().AddChild(inverterNode); } _parentNodeStack.Push(inverterNode); return(this); }
public void ProfilerResult() { var invert = new InverterNode <int, int>(); var profiler = new LogProfiler <int>(); var node = new ActionNode <int, int>("test", (p1, p2) => { return(BehaviourTreeState.Success); }); invert.Decorate(node); invert.Profiler = profiler; var func = invert.Compile(); var state = func(0, 0); // Assert.Equal(expectedState, state); }
public async Task RunAsync_ShouldReturnSucceeded_WhenChildFails() { // Arrange var child = new Mock <Node <object> >(); child.Setup(c => c.RunAsync()) .Returns(new ValueTask <ResultType>(ResultType.Failed)); var node = new InverterNode <object>("", child.Object); // Act await node.BeforeRunAsync(); var result = await node.RunAsync(); // Assert Assert.Equal(ResultType.Succeeded, result); }
public void ViewfulPipeline() { var input = new VideoInputNode { FileName = new FilePath(@"..\..\..\..\resources\americanFootball_352x240_125.yuv") }; Func <Node, Node> makeNode = n => { Node n2 = new InverterNode(); n2.Inputs[0].Source = n.Outputs[0]; return(n2); }; Node graph = makeNode(makeNode(makeNode(input))); IoC.GetInstance = delegate { return(new EventAggregator()); }; var output = new VideoOutputViewModel(graph.Outputs[0]); var sw = Stopwatch.StartNew(); new PipelineDriver().RenderTicks(new[] { graph }, tickCount: input.TickCount) .ForEach(dic => output.Handle(new TickRenderedMessage(dic))); Console.WriteLine(sw.ElapsedMilliseconds + " ms"); }
// Start is called before the first frame update void Start() { Self = gameObject; treeFrontNode = new SelectorNode("Root"); SequenceNode StandNode = new SequenceNode("Stand"); ConditionNode isInFieldNode = new ConditionNode("InField", IsInField); ConditionNode isAttackedNode = new ConditionNode("isAttacked", IsAttacked); InverterNode isNotAttackedNode = new InverterNode("isNotAttacked", isAttackedNode); ActionNode standActionNode = new ActionNode("站立", OnStandAction); StandNode.addChild(isInFieldNode); StandNode.addChild(isNotAttackedNode); StandNode.addChild(standActionNode); SequenceNode AttackNode = new SequenceNode("Attack"); SequenceNode RebackNode = new SequenceNode("Reback"); treeFrontNode.addChild(StandNode); treeFrontNode.addChild(AttackNode); treeFrontNode.addChild(RebackNode); }
public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game) { UnitHasRouteNode unitHasRoute0000 = new UnitHasRouteNode("unitHasRoute0000", behaviorTree, unit); LanceHasStartedRouteNode lanceHasStartedRoute0000 = new LanceHasStartedRouteNode("lanceHasStartedRoute0000", behaviorTree, unit); LanceStartRouteNode lanceStartRoute0000 = new LanceStartRouteNode("lanceStartRoute0000", behaviorTree, unit); SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit); selector0000.AddChild(lanceHasStartedRoute0000); selector0000.AddChild(lanceStartRoute0000); LanceHasCompletedRouteNode lanceHasCompletedRoute0000 = new LanceHasCompletedRouteNode("lanceHasCompletedRoute0000", behaviorTree, unit); InverterNode inverter0000 = new InverterNode("inverter0000", behaviorTree, unit); inverter0000.AddChild(lanceHasCompletedRoute0000); MoveAlongRouteNode moveAlongRoute0000 = new MoveAlongRouteNode("moveAlongRoute0000", behaviorTree, unit); SequenceNode incrementally_patrol = new SequenceNode("incrementally_patrol", behaviorTree, unit); incrementally_patrol.AddChild(unitHasRoute0000); incrementally_patrol.AddChild(selector0000); incrementally_patrol.AddChild(inverter0000); incrementally_patrol.AddChild(moveAlongRoute0000); BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit); SelectorNode route_AI_root = new SelectorNode("route_AI_root", behaviorTree, unit); route_AI_root.AddChild(incrementally_patrol); route_AI_root.AddChild(brace0000); return(route_AI_root); }
public void TestInverter() { YuvKA.VideoModel.Size testSize = new YuvKA.VideoModel.Size(5, 5); Frame[] inputs = { new Frame(testSize) }; for (int x = 0; x < testSize.Width; x++) { for (int y = 0; y < testSize.Height; y++) { inputs[0][x, y] = new Rgb((byte)(x + y), (byte)(x + y), (byte)(x + y)); } } InverterNode inverter = new InverterNode(); Frame[] result = inverter.Process(inputs, 0); for (int x = 0; x < testSize.Width; x++) { for (int y = 0; y < testSize.Height; y++) { Assert.Equal(255 - inputs[0][x, y].R, result[0][x, y].R); Assert.Equal(255 - inputs[0][x, y].G, result[0][x, y].G); Assert.Equal(255 - inputs[0][x, y].B, result[0][x, y].B); } } }
public async Task RunAsync_ShouldReturnRunningAndTriggerEventWithFailed_WhenChildRunsThenSucceeds() { // Arrange var child = new TestNode(); var node = new InverterNode <object>("", child); ResultType?nodeResult = null; node.Finished += (r) => { nodeResult = r; }; // Act await node.BeforeRunAsync(); var result = await node.RunAsync(); child.TriggerFinishedEvent(ResultType.Succeeded); // Assert Assert.Equal(ResultType.Running, result); Assert.NotNull(nodeResult); Assert.Equal(ResultType.Failed, nodeResult); }
public override void Run() { blackBoard = new TestBlackboard(typeof(TestBlackboard.Vars)); tree = new TestTree(blackBoard, this); blackBoard.setData(TestBlackboard.Vars.FirePower, 5d); blackBoard.setData(TestBlackboard.Vars.LastScan, -10d); blackBoard.setData(TestBlackboard.Vars.ScanDelay, 5d); blackBoard.setData(TestBlackboard.Vars.MaxDist, 300d); //Build Tree { DecoratorNode repeater = new RepeatUntilWinNode(); tree.SetMaster(repeater); CompositeNode sequencer = new SequenceNode(); repeater.setChild(sequencer); //Scanning { DecoratorNode scanInverter1 = new InverterNode(); sequencer.addChild(scanInverter1); CompositeNode scanSequencer = new SequenceNode(); scanInverter1.setChild(scanSequencer); DecoratorNode scanInverter2 = new InverterNode(); scanSequencer.addChild(new ChangeColorNode(Color.Blue)); scanSequencer.addChild(scanInverter2); scanInverter2.setChild(new RecentlyScannedNode()); scanSequencer.addChild(new ScanNode()); } CompositeNode selector = new SelectorNode(); sequencer.addChild(selector); //Move to range { CompositeNode MoveToRangeSequencer = new SequenceNode(); selector.addChild(MoveToRangeSequencer); MoveToRangeSequencer.addChild(new ChangeColorNode(Color.Green)); MoveToRangeSequencer.addChild(new RecentlyScannedNode()); DecoratorNode MoveToRangeInverter = new InverterNode(); MoveToRangeSequencer.addChild(MoveToRangeInverter); MoveToRangeInverter.setChild(new InRangeNode()); MoveToRangeSequencer.addChild(new TurnTowardsNode()); MoveToRangeSequencer.addChild(new DriveNode()); } // Shooting { CompositeNode shootingSequencer = new SequenceNode(); selector.addChild(shootingSequencer); shootingSequencer.addChild(new ChangeColorNode(Color.Red)); shootingSequencer.addChild(new CheckGunHeatNode()); shootingSequencer.addChild(new ScanNode()); shootingSequencer.addChild(new ShootNode()); } selector.addChild(new DoNothingNode()); } Out.WriteLine("Created Behaviour tree"); //Run Tree { BTNode.Status s; do { s = tree.process(); }while(s == BTNode.Status.Running); } }
void Init() { testObject = new InverterNode("some-node"); }
private Inverter <TContext> MapInverterNode(InverterNode node) { return(new Inverter <TContext>(node.Name, Map(node.Child))); }
public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game) { IsShutDownNode isShutdown0000 = new IsShutDownNode("isShutdown0000", behaviorTree, unit); MechStartUpNode mechStartUp0000 = new MechStartUpNode("mechStartUp0000", behaviorTree, unit); SequenceNode if_shutdown__restart = new SequenceNode("if_shutdown__restart", behaviorTree, unit); if_shutdown__restart.AddChild(isShutdown0000); if_shutdown__restart.AddChild(mechStartUp0000); IsMovementAvailableForUnitNode movementAvailable0000 = new IsMovementAvailableForUnitNode("movementAvailable0000", behaviorTree, unit); IsProneNode isProne0000 = new IsProneNode("isProne0000", behaviorTree, unit); StandNode stand0000 = new StandNode("stand0000", behaviorTree, unit); SequenceNode if_prone__stand_up = new SequenceNode("if_prone__stand_up", behaviorTree, unit); if_prone__stand_up.AddChild(movementAvailable0000); if_prone__stand_up.AddChild(isProne0000); if_prone__stand_up.AddChild(stand0000); IsMovementAvailableForUnitNode movementAvailable0001 = new IsMovementAvailableForUnitNode("movementAvailable0001", behaviorTree, unit); HasSensorLockAbilityNode hasSensorLockAbility0000 = new HasSensorLockAbilityNode("hasSensorLockAbility0000", behaviorTree, unit); HasSensorLockTargetNode hasSensorLockTarget0000 = new HasSensorLockTargetNode("hasSensorLockTarget0000", behaviorTree, unit); SortEnemiesBySensorLockQualityNode sortEnemiesBySensorLockQuality0000 = new SortEnemiesBySensorLockQualityNode("sortEnemiesBySensorLockQuality0000", behaviorTree, unit); RecordHighestPriorityEnemyAsSensorLockTargetNode recordHighestPriorityEnemyAsSensorLockTarget0000 = new RecordHighestPriorityEnemyAsSensorLockTargetNode("recordHighestPriorityEnemyAsSensorLockTarget0000", behaviorTree, unit); SequenceNode sensor_lock_success = new SequenceNode("sensor_lock_success", behaviorTree, unit); sensor_lock_success.AddChild(hasSensorLockAbility0000); sensor_lock_success.AddChild(hasSensorLockTarget0000); sensor_lock_success.AddChild(sortEnemiesBySensorLockQuality0000); sensor_lock_success.AddChild(recordHighestPriorityEnemyAsSensorLockTarget0000); ClearSensorLockNode clearSensorLock0000 = new ClearSensorLockNode("clearSensorLock0000", behaviorTree, unit); SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit); selector0000.AddChild(sensor_lock_success); selector0000.AddChild(clearSensorLock0000); SequenceNode evalSensorLock = new SequenceNode("evalSensorLock", behaviorTree, unit); evalSensorLock.AddChild(selector0000); SuccessDecoratorNode maybe_sensor_lock = new SuccessDecoratorNode("maybe_sensor_lock", behaviorTree, unit); maybe_sensor_lock.AddChild(evalSensorLock); UnitHasRouteNode unitHasRoute0000 = new UnitHasRouteNode("unitHasRoute0000", behaviorTree, unit); LanceHasCompletedRouteNode lanceHasCompletedRoute0000 = new LanceHasCompletedRouteNode("lanceHasCompletedRoute0000", behaviorTree, unit); InverterNode inverter0000 = new InverterNode("inverter0000", behaviorTree, unit); inverter0000.AddChild(lanceHasCompletedRoute0000); LanceHasStartedRouteNode lanceHasStartedRoute0000 = new LanceHasStartedRouteNode("lanceHasStartedRoute0000", behaviorTree, unit); LanceStartRouteNode lanceStartRoute0000 = new LanceStartRouteNode("lanceStartRoute0000", behaviorTree, unit); SelectorNode selector0001 = new SelectorNode("selector0001", behaviorTree, unit); selector0001.AddChild(lanceHasStartedRoute0000); selector0001.AddChild(lanceStartRoute0000); BlockUntilPathfindingReadyNode blockUntilPathfindingReady0000 = new BlockUntilPathfindingReadyNode("blockUntilPathfindingReady0000", behaviorTree, unit); MoveAlongRouteNode moveAlongRoute0000 = new MoveAlongRouteNode("moveAlongRoute0000", behaviorTree, unit); SequenceNode move_along_route = new SequenceNode("move_along_route", behaviorTree, unit); move_along_route.AddChild(movementAvailable0001); move_along_route.AddChild(maybe_sensor_lock); move_along_route.AddChild(unitHasRoute0000); move_along_route.AddChild(inverter0000); move_along_route.AddChild(selector0001); move_along_route.AddChild(blockUntilPathfindingReady0000); move_along_route.AddChild(moveAlongRoute0000); HasSensorLockAbilityNode hasSensorLockAbility0001 = new HasSensorLockAbilityNode("hasSensorLockAbility0001", behaviorTree, unit); HasRecordedSensorLockTargetNode hasRecordedSensorLockTarget0000 = new HasRecordedSensorLockTargetNode("hasRecordedSensorLockTarget0000", behaviorTree, unit); SetMoodNode setMood0000 = new SetMoodNode("setMood0000", behaviorTree, unit, AIMood.Aggressive); SensorLockRecordedSensorLockTargetNode sensorLockRecordedSensorLockTarget0000 = new SensorLockRecordedSensorLockTargetNode("sensorLockRecordedSensorLockTarget0000", behaviorTree, unit); SequenceNode choseToSensorLock = new SequenceNode("choseToSensorLock", behaviorTree, unit); choseToSensorLock.AddChild(hasSensorLockAbility0001); choseToSensorLock.AddChild(hasRecordedSensorLockTarget0000); choseToSensorLock.AddChild(setMood0000); choseToSensorLock.AddChild(sensorLockRecordedSensorLockTarget0000); LanceDetectsEnemiesNode lanceDetectsEnemies0000 = new LanceDetectsEnemiesNode("lanceDetectsEnemies0000", behaviorTree, unit); FindDetectedEnemiesNode findDetectedEnemies0000 = new FindDetectedEnemiesNode("findDetectedEnemies0000", behaviorTree, unit); IsAttackAvailableForUnitNode attackAvailable0000 = new IsAttackAvailableForUnitNode("attackAvailable0000", behaviorTree, unit); SortEnemiesByThreatNode sortEnemiesByThreat0000 = new SortEnemiesByThreatNode("sortEnemiesByThreat0000", behaviorTree, unit); UseNormalToHitThreshold useNormalToHitThreshold0000 = new UseNormalToHitThreshold("useNormalToHitThreshold0000", behaviorTree, unit); WasTargetedRecentlyNode wasTargetedRecently0000 = new WasTargetedRecentlyNode("wasTargetedRecently0000", behaviorTree, unit); InverterNode inverter0001 = new InverterNode("inverter0001", behaviorTree, unit); inverter0001.AddChild(wasTargetedRecently0000); RandomPercentageLessThanBVNode randomPercentageLessThanBV0000 = new RandomPercentageLessThanBVNode("randomPercentageLessThanBV0000", behaviorTree, unit, BehaviorVariableName.Float_PriorityAttackPercentage); SortEnemiesByPriorityListNode sortEnemiesByPriorityList0000 = new SortEnemiesByPriorityListNode("sortEnemiesByPriorityList0000", behaviorTree, unit); SequenceNode sequence0000 = new SequenceNode("sequence0000", behaviorTree, unit); sequence0000.AddChild(inverter0001); sequence0000.AddChild(randomPercentageLessThanBV0000); sequence0000.AddChild(sortEnemiesByPriorityList0000); MaybeFilterOutPriorityTargetsNode maybeFilterOutPriorityTargets0000 = new MaybeFilterOutPriorityTargetsNode("maybeFilterOutPriorityTargets0000", behaviorTree, unit); FilterKeepingRecentAttackersNode filterKeepingRecentAttackers0000 = new FilterKeepingRecentAttackersNode("filterKeepingRecentAttackers0000", behaviorTree, unit); SucceedNode succeed0000 = new SucceedNode("succeed0000", behaviorTree, unit); SelectorNode priorityAttack = new SelectorNode("priorityAttack", behaviorTree, unit); priorityAttack.AddChild(sequence0000); priorityAttack.AddChild(maybeFilterOutPriorityTargets0000); priorityAttack.AddChild(filterKeepingRecentAttackers0000); priorityAttack.AddChild(succeed0000); ShootAtHighestPriorityEnemyNode shootAtHighestPriorityEnemy0000 = new ShootAtHighestPriorityEnemyNode("shootAtHighestPriorityEnemy0000", behaviorTree, unit); SequenceNode opportunity_fire = new SequenceNode("opportunity_fire", behaviorTree, unit); opportunity_fire.AddChild(lanceDetectsEnemies0000); opportunity_fire.AddChild(findDetectedEnemies0000); opportunity_fire.AddChild(attackAvailable0000); opportunity_fire.AddChild(sortEnemiesByThreat0000); opportunity_fire.AddChild(useNormalToHitThreshold0000); opportunity_fire.AddChild(priorityAttack); opportunity_fire.AddChild(shootAtHighestPriorityEnemy0000); BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit); SelectorNode patrol_and_shoot_AI_root = new SelectorNode("patrol_and_shoot_AI_root", behaviorTree, unit); patrol_and_shoot_AI_root.AddChild(if_shutdown__restart); patrol_and_shoot_AI_root.AddChild(if_prone__stand_up); patrol_and_shoot_AI_root.AddChild(move_along_route); patrol_and_shoot_AI_root.AddChild(choseToSensorLock); patrol_and_shoot_AI_root.AddChild(opportunity_fire); patrol_and_shoot_AI_root.AddChild(brace0000); return(patrol_and_shoot_AI_root); }
void GenerateMarineBTv100() { BTNode f0 = new FallbackNode(unit); BTNode s0 = new SequenceNode(unit); f0.children.Add(s0); BTNode c0 = new IsCommandIdle(unit); s0.children.Add(c0); BTNode c1 = new BeingShotAt(unit); s0.children.Add(c1); BTNode sf0 = new RSF0(unit); s0.children.Add(sf0); BTNode f1 = new FallbackNode(unit); sf0.children.Add(f1); BTNode a0 = new TakeCover(unit, emptySlot); f1.children.Add(a0); BTNode a1 = new Charge(unit); f1.children.Add(a1); BTNode a2 = new Charge(unit); sf0.children.Add(a2); BTNode s1 = new SequenceNode(unit); f0.children.Add(s1); BTNode c2 = new IsCommandMove(unit); s1.children.Add(c2); BTNode f2 = new FallbackNode(unit); s1.children.Add(f2); BTNode s2 = new SequenceNode(unit); f2.children.Add(s2); BTNode c3 = new BeingShotAt(unit); s2.children.Add(c3); BTNode sf1 = new CSF0(unit, 70f); s2.children.Add(sf1); BTNode a3 = new RunToTheHills(unit); sf1.children.Add(a3); BTNode f3 = new FallbackNode(unit); sf1.children.Add(f3); BTNode s3 = new SequenceNode(unit); f3.children.Add(s3); BTNode c4 = new Overwhelmed(unit); s3.children.Add(c4); BTNode f4 = new FallbackNode(unit); s3.children.Add(f4); BTNode a4 = new TakeCover(unit, emptySlot); f4.children.Add(a4); BTNode a5 = new RunToTheHills(unit); f4.children.Add(a5); BTNode a6 = new PushForward(unit); f3.children.Add(a6); BTNode s4 = new SequenceNode(unit); f2.children.Add(s4); BTNode w0 = new InverterNode(unit); s4.children.Add(w0); BTNode c5 = new AtTargetLocation(unit); w0.children.Add(c5); BTNode a7 = new GoTowardsTargetLocation(unit); s4.children.Add(a7); BTNode a8 = new MakeUnitIdle(unit); f2.children.Add(a8); BTNode s5 = new SequenceNode(unit); f0.children.Add(s5); BTNode c6 = new IsCommandHoldPosition(unit); s5.children.Add(c6); BTNode f5 = new FallbackNode(unit); s5.children.Add(f5); BTNode s6 = new SequenceNode(unit); f5.children.Add(s6); BTNode f6 = new FallbackNode(unit); s6.children.Add(f6); BTNode c7 = new BeingShotAt(unit); f6.children.Add(c7); BTNode c8 = new IsEnemyNearby(unit); f6.children.Add(c8); BTNode f7 = new FallbackNode(unit); s6.children.Add(f7); BTNode a9 = new TakeCover(unit, emptySlot); f7.children.Add(a9); BTNode a10 = new PushForward(unit); f7.children.Add(a10); BTNode s7 = new SequenceNode(unit); f5.children.Add(s7); BTNode w1 = new InverterNode(unit); s7.children.Add(w1); BTNode c9 = new AtTargetLocation(unit); w1.children.Add(c9); BTNode a11 = new GoTowardsTargetLocation(unit); s7.children.Add(a11); BTNode s8 = new SequenceNode(unit); f5.children.Add(s8); BTNode a12 = new Diffuse(unit, emptySlot); s8.children.Add(a12); BTNode a13 = new MakeUnitInPosition(unit); s8.children.Add(a13); BTNode s9 = new SequenceNode(unit); f0.children.Add(s9); BTNode c10 = new IsCommandInPosition(unit); s9.children.Add(c10); BTNode c11 = new BeingShotAt(unit); s9.children.Add(c11); BTNode sf2 = new CSF0(unit, 100f); s9.children.Add(sf2); BTNode a14 = new Charge(unit); sf2.children.Add(a14); BTNode a15 = new TakeCover(unit, emptySlot); s9.children.Add(a15); root = f0; }
void Init() { testObject = new InverterNode <TimeData>("some-node"); }
private void DiagramAddDefaultItem(string type, Diagram diagram, Point p) { switch (type) { case "AndGate": { var node = new AndGateNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "OrGate": { var node = new OrGateNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "Inverter": { var node = new InverterNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "Pulse": { var node = new PulseNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "PulseGenerator": { var node = new PulseGeneratorNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "TimerOffDelay": { var node = new TimerOffDelayNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "TimerOnDelay": { var node = new TimerOnDelayNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "MemoryResetPriority": { var node = new MemoryResetPriorityNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "MemorySetPriority": { var node = new MemorySetPriorityNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "Limiter": { var node = new LimiterNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "LowerLimit": { var node = new LowerLimitNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "HigherLimit": { var node = new HigherLimitNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "DeadBand": { var node = new DeadBandNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "Multiplier": { var node = new MultiplierNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "PiController": { var node = new PiControllerNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "PidController": { var node = new PidControllerNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "SignalSwitch": { var node = new SignalSwitchNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "SignalTransmitter": { var node = new SignalTransmitterNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "MinimumSelector": { var node = new MinimumSelectorNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; case "MaximumSelector": { var node = new MaximumSelectorNode() { Id = Guid.NewGuid(), X = p.X, Y = p.Y, Z = 1 }; node.CreateDefaultPins(); node.Update(diagram); diagram.Items.Add(node); } break; default: { } break; } }
public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game) { IsShutDownNode isShutdown0000 = new IsShutDownNode("isShutdown0000", behaviorTree, unit); MechStartUpNode mechStartUp0000 = new MechStartUpNode("mechStartUp0000", behaviorTree, unit); SequenceNode if_shutdown__restart = new SequenceNode("if_shutdown__restart", behaviorTree, unit); if_shutdown__restart.AddChild(isShutdown0000); if_shutdown__restart.AddChild(mechStartUp0000); IsMovementAvailableForUnitNode movementAvailable0000 = new IsMovementAvailableForUnitNode("movementAvailable0000", behaviorTree, unit); IsProneNode isProne0000 = new IsProneNode("isProne0000", behaviorTree, unit); StandNode stand0000 = new StandNode("stand0000", behaviorTree, unit); SequenceNode if_prone__stand_up = new SequenceNode("if_prone__stand_up", behaviorTree, unit); if_prone__stand_up.AddChild(movementAvailable0000); if_prone__stand_up.AddChild(isProne0000); if_prone__stand_up.AddChild(stand0000); IsMovementAvailableForUnitNode movementAvailable0001 = new IsMovementAvailableForUnitNode("movementAvailable0001", behaviorTree, unit); UnitHasRouteNode unitHasRoute0000 = new UnitHasRouteNode("unitHasRoute0000", behaviorTree, unit); LanceHasStartedRouteNode lanceHasStartedRoute0000 = new LanceHasStartedRouteNode("lanceHasStartedRoute0000", behaviorTree, unit); LanceStartRouteNode lanceStartRoute0000 = new LanceStartRouteNode("lanceStartRoute0000", behaviorTree, unit); SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit); selector0000.AddChild(lanceHasStartedRoute0000); selector0000.AddChild(lanceStartRoute0000); LanceHasCompletedRouteNode lanceHasCompletedRoute0000 = new LanceHasCompletedRouteNode("lanceHasCompletedRoute0000", behaviorTree, unit); InverterNode inverter0000 = new InverterNode("inverter0000", behaviorTree, unit); inverter0000.AddChild(lanceHasCompletedRoute0000); MoveAlongRouteNode moveAlongRoute0000 = new MoveAlongRouteNode("moveAlongRoute0000", behaviorTree, unit); SequenceNode patrol_opportunistic_shoot = new SequenceNode("patrol_opportunistic_shoot", behaviorTree, unit); patrol_opportunistic_shoot.AddChild(movementAvailable0001); patrol_opportunistic_shoot.AddChild(unitHasRoute0000); patrol_opportunistic_shoot.AddChild(selector0000); patrol_opportunistic_shoot.AddChild(inverter0000); patrol_opportunistic_shoot.AddChild(moveAlongRoute0000); LanceDetectsEnemiesNode lanceDetectsEnemies0000 = new LanceDetectsEnemiesNode("lanceDetectsEnemies0000", behaviorTree, unit); FindDetectedEnemiesNode findDetectedEnemies0000 = new FindDetectedEnemiesNode("findDetectedEnemies0000", behaviorTree, unit); IsAttackAvailableForUnitNode attackAvailable0000 = new IsAttackAvailableForUnitNode("attackAvailable0000", behaviorTree, unit); SortEnemiesByThreatNode sortEnemiesByThreat0000 = new SortEnemiesByThreatNode("sortEnemiesByThreat0000", behaviorTree, unit); UseNormalToHitThreshold useNormalToHitThreshold0000 = new UseNormalToHitThreshold("useNormalToHitThreshold0000", behaviorTree, unit); WasTargetedRecentlyNode wasTargetedRecently0000 = new WasTargetedRecentlyNode("wasTargetedRecently0000", behaviorTree, unit); InverterNode inverter0001 = new InverterNode("inverter0001", behaviorTree, unit); inverter0001.AddChild(wasTargetedRecently0000); RandomPercentageLessThanBVNode randomPercentageLessThanBV0000 = new RandomPercentageLessThanBVNode("randomPercentageLessThanBV0000", behaviorTree, unit, BehaviorVariableName.Float_PriorityAttackPercentage); SortEnemiesByPriorityListNode sortEnemiesByPriorityList0000 = new SortEnemiesByPriorityListNode("sortEnemiesByPriorityList0000", behaviorTree, unit); SequenceNode sequence0000 = new SequenceNode("sequence0000", behaviorTree, unit); sequence0000.AddChild(inverter0001); sequence0000.AddChild(randomPercentageLessThanBV0000); sequence0000.AddChild(sortEnemiesByPriorityList0000); MaybeFilterOutPriorityTargetsNode maybeFilterOutPriorityTargets0000 = new MaybeFilterOutPriorityTargetsNode("maybeFilterOutPriorityTargets0000", behaviorTree, unit); FilterKeepingRecentAttackersNode filterKeepingRecentAttackers0000 = new FilterKeepingRecentAttackersNode("filterKeepingRecentAttackers0000", behaviorTree, unit); SequenceNode sequence0001 = new SequenceNode("sequence0001", behaviorTree, unit); sequence0001.AddChild(maybeFilterOutPriorityTargets0000); sequence0001.AddChild(filterKeepingRecentAttackers0000); SucceedNode succeed0000 = new SucceedNode("succeed0000", behaviorTree, unit); SelectorNode priorityAttack = new SelectorNode("priorityAttack", behaviorTree, unit); priorityAttack.AddChild(sequence0000); priorityAttack.AddChild(sequence0001); priorityAttack.AddChild(succeed0000); ShootAtHighestPriorityEnemyNode shootAtHighestPriorityEnemy0000 = new ShootAtHighestPriorityEnemyNode("shootAtHighestPriorityEnemy0000", behaviorTree, unit); SequenceNode opportunity_fire = new SequenceNode("opportunity_fire", behaviorTree, unit); opportunity_fire.AddChild(lanceDetectsEnemies0000); opportunity_fire.AddChild(findDetectedEnemies0000); opportunity_fire.AddChild(attackAvailable0000); opportunity_fire.AddChild(sortEnemiesByThreat0000); opportunity_fire.AddChild(useNormalToHitThreshold0000); opportunity_fire.AddChild(priorityAttack); opportunity_fire.AddChild(shootAtHighestPriorityEnemy0000); BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit); SelectorNode patrol_With_Opportunistic_Shooting_AI_root = new SelectorNode("patrol_With_Opportunistic_Shooting_AI_root", behaviorTree, unit); patrol_With_Opportunistic_Shooting_AI_root.AddChild(if_shutdown__restart); patrol_With_Opportunistic_Shooting_AI_root.AddChild(if_prone__stand_up); patrol_With_Opportunistic_Shooting_AI_root.AddChild(patrol_opportunistic_shoot); patrol_With_Opportunistic_Shooting_AI_root.AddChild(opportunity_fire); patrol_With_Opportunistic_Shooting_AI_root.AddChild(brace0000); return(patrol_With_Opportunistic_Shooting_AI_root); }
protected void DefineNode() { // RunningFromEnemy n_GetClosestEnemy = new LeafNode(GetClosestEnemy_node); n_IsPlayerPowerHigerThanEnemy = new LeafNode(IsPlayerPowerHigerThanEnemy); n_MeetWithDestination = new LeafNode(MeetWithDestination); n_BackToTowerAction = new LeafNode(BackToTowerAction); n_IsPlayerPowerLowerThanEnemy = new InverterNode(n_IsPlayerPowerHigerThanEnemy); n_BackToTower = new SelectorNode(new List <Node> { n_MeetWithDestination, n_BackToTowerAction }); n_RunningFromEnemy = new SequenceNode(new List <Node> { n_GetClosestEnemy, n_IsPlayerPowerLowerThanEnemy, n_BackToTower }); //end running // goto nearest checkpoint n_IsAlreadyHaveDestination = new LeafNode(IsAlreadyHaveDestination); n_GetNearestCheckPoint = new LeafNode(GetNearestCheckPoint); n_MeetWithDestinationCheckPoint = new LeafNode(MeetWithDestination); n_GotoCheckPointAction = new LeafNode(GotoCheckPointAction); n_SetDestinationCheckpoint = new SelectorNode(new List <Node> { n_IsAlreadyHaveDestination, n_GetNearestCheckPoint }); n_GotoCheckPoint = new SelectorNode(new List <Node> { n_MeetWithDestinationCheckPoint, n_GotoCheckPointAction }); n_GotoNearestCheckpoint = new SequenceNode(new List <Node> { n_SetDestinationCheckpoint, n_GotoCheckPoint }); //end nearest //Back to tower if power is critical n_CheckIfPowerisCritical = new LeafNode(CheckIfPowerIsCritical); n_BackToTowerifPowerIsCritical = new SequenceNode(new List <Node>() { n_CheckIfPowerisCritical, n_BackToTower }); //end back n_root = new SelectorNode(new List <Node> { n_BackToTowerifPowerIsCritical, n_RunningFromEnemy, n_GotoNearestCheckpoint }); }