# Random Task in AI

**URL:** <https://forums.unrealengine.com/t/random-task-in-ai/396188>\
**Category:** AI\
**Tags:** ai-navigation, Behavior-Tree, unreal-engine, Blueprint, question\
**Created:** [June 15, 2017, 11:47am UTC](https://forums.unrealengine.com/t/random-task-in-ai/396188 "2017-06-15T11:47:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jiyko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jiyko](https://forums.unrealengine.com/u/Jiyko)\
**Post date:** [June 15, 2017, 11:47am UTC](https://forums.unrealengine.com/t/random-task-in-ai/396188/1 "2017-06-15T11:47:32Z")

</div>

Hi all,  
I want the behavior tree to randomly do one of the tasks below a selector. Don’t care which task.  
My current solution is to randomly Finish Execute with a fail so it goes to the next one. It works but it doesn’t feel clean.

Is there a cleaner solution?

 ![190657-aitree.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/f/e6fde37b476752e9bda25ef0dfe3394c0b030540.png)

---

<div class="post-metadata">

**Author:** ![navid100](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@navid100](https://forums.unrealengine.com/u/navid100)\
**Post date:** [June 15, 2017, 1:04pm UTC](https://forums.unrealengine.com/t/random-task-in-ai/396188/2 "2017-06-15T13:04:34Z")

</div>

Hi,

You can create a ‘Service’ and assign a random integer to a blackboard value and then on each task, use ‘blackboard condition’ decorator to check that integer value. Here, take a look at this very simple setup for a better understanding;

Blackboard

 ![200642-bb.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/b/37bafb05d058a28c2ab8d758d5d5d98da93304d5.png)

Behavior Tree

 ![200643-bt.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/e/56e8f0c5c0f8b9da44879814e1beabb3a6c99281.png)

Service

 ![200644-service.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/3/1a332a86ffe39ecc7dbe885c01770c2a3e49a5a5.png)

Assign the service value to blackboard value.

![200646-bb+&+bt+interface.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/9/9493166c384a1a6ebf4b125987332312213809e9.png)

First Task

 ![200645-firsttask.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/a/7fa32ca202018e85fde17f58d81c13332aaabcea.png)

Note that in this approach, the selector only picks one random task to execute. Hope it help.

Regards,

---

<div class="post-metadata">

**Author:** ![Jiyko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jiyko](https://forums.unrealengine.com/u/Jiyko)\
**Post date:** [June 15, 2017, 3:25pm UTC](https://forums.unrealengine.com/t/random-task-in-ai/396188/3 "2017-06-15T15:25:56Z")

</div>

This works! Cheers.
