Coordinating AI agents
Hello AI-experts,
The AI project has moved briskly along since I started it 5 months ago. The next item on my plate is getting the AI agents to cooperate in groups of 2 or more.
These are some of the tasks and behaviours that I want to implement:
- Moving as a group
- Sharing a vehicle
- Escorting
- Performing salvage/rescue operations
- Doing big-game hunting or combat operations
- Various social activities which will be handled in an abstracted fashion, such as eating dinner or playing football.
I have identified the following commonalites between these tasks:
Agent groups are formed around a task and dissolved again
Someone takes initiative and others join in (if they don't, then what?)
Agents enter and exit groups
Agents either wait for each other or decide that they have waited too long
Agents are in a special 'mode' when they are cooperating, meaning they are attuned to what the other members are doing
Agents should share information and status
Someone should take charge and decide on destinations etc.
The question is if there is a smart design that will allow me to encapsulate (or avoid?) the extensive messaging that will probably be required. I have heard of blackboard systems but I do not know of any finished designs.
The AI framework I am using is the goal-based system described in 'Programming Game AI By Example'
The game I'm working on in my spare time
I haven't implemented it myself, but the approach outlined in "Social Activities: Implementing Wittgenstein" is the first thing I would try. If you haven't encountered that article before, read it and take some time to think of those collaborative behaviors as activities. It will probably all make sense.
This notion of activity can be extended to get all sorts of interesting behavior if you allow activities to modify the utility functions of individual agents. This is something I've been thinking about for a long time now but, again, I haven't implemented it yet, so there might be some serious obstacles that I am not aware of.
This notion of activity can be extended to get all sorts of interesting behavior if you allow activities to modify the utility functions of individual agents. This is something I've been thinking about for a long time now but, again, I haven't implemented it yet, so there might be some serious obstacles that I am not aware of.
Interesting article, 'activity' is a useful term I think.
One point that must be addressed is how activities get started. I see two options:
1. The agent posts a request to a central 'bulletin board' to start the activity. Then other agents can see it and 'sign up'.
2. The agent sends messages to all or some other agents containing the request.
The downside of 1 is that other agents are not able to interrupt whatever they are currently doing in order to take part in the activity instead. The requesting agent must wait until the others are ready and run their action arbitration procedure. And what should he do while waiting?
Option 2 makes it possible for the others to interrupt what they are doing, by either cancelling their current goal or adding the activity as a subgoal. Also, the requesting agent gets his answer right away.
The downside is that message handling for many different activity requests must be included in the code of the various goals.
I think there needs to be a priority system in place to handle general priorities between activities, similar to the linked article's example of an agent interrupting a conversation to go to the bathroom (it could be urgent, though, in which case it would be OK).
One point that must be addressed is how activities get started. I see two options:
1. The agent posts a request to a central 'bulletin board' to start the activity. Then other agents can see it and 'sign up'.
2. The agent sends messages to all or some other agents containing the request.
The downside of 1 is that other agents are not able to interrupt whatever they are currently doing in order to take part in the activity instead. The requesting agent must wait until the others are ready and run their action arbitration procedure. And what should he do while waiting?
Option 2 makes it possible for the others to interrupt what they are doing, by either cancelling their current goal or adding the activity as a subgoal. Also, the requesting agent gets his answer right away.
The downside is that message handling for many different activity requests must be included in the code of the various goals.
I think there needs to be a priority system in place to handle general priorities between activities, similar to the linked article's example of an agent interrupting a conversation to go to the bathroom (it could be urgent, though, in which case it would be OK).
Quote: I see two options:
1. The agent posts a request to a central 'bulletin board' to start the activity. Then other agents can see it and 'sign up'.
2. The agent sends messages to all or some other agents containing the request.
There is a third option. Allow agents the ability to ask the other what it is doing. Then if an agent is free, it can ask the "nearest" agent what it is doing and join in.
Now nearest might not be strictly spatial (but could be), but instead you could have all sorts of measures (like related to their last activity, production line number, or whatever but it will likely be spatial none the less).
I am not sure if I understand the advantage of the third option you suggest - perhaps you can explain it further...
It would be useful to join 1 and 2 I think.
This enables an activity to get started quickly by inviting all agents. At the same time a request is posted on the bulletin board so others can join in along the way. This way, I don't have to handle the request in each and every goal.
The bulletin board should be for 'global' activities I think. Other activities should be announced with a trigger to those close by.
It would be useful to join 1 and 2 I think.
This enables an activity to get started quickly by inviting all agents. At the same time a request is posted on the bulletin board so others can join in along the way. This way, I don't have to handle the request in each and every goal.
The bulletin board should be for 'global' activities I think. Other activities should be announced with a trigger to those close by.
I would start with a notification of surrounding subjects, maybe via an announcement, that your initiator can send to everything within a certain radius. Then maybe, if you wanted to keep it smaller, an event can be announced only to people that the initiator talks to.
A good broad-scale implementation, which may be hard on memory space but would be great for other interactive dynamics would be to have each individual have a list of friend-individuals, and they then could notify people in their friends who might be interested in such an activity.
And, for determining who goes and who stays, use a priority queue. When something comes up, if it's more important than the current objective, it replaces it. If not, it waits. You could even stack priority queues, so that an object of significantly greater importance would interrupt immediately, whereas an event of similar importance could wait until the current objective is completed.
A good broad-scale implementation, which may be hard on memory space but would be great for other interactive dynamics would be to have each individual have a list of friend-individuals, and they then could notify people in their friends who might be interested in such an activity.
And, for determining who goes and who stays, use a priority queue. When something comes up, if it's more important than the current objective, it replaces it. If not, it waits. You could even stack priority queues, so that an object of significantly greater importance would interrupt immediately, whereas an event of similar importance could wait until the current objective is completed.
Actually, the board idea has some merit. Instead of using it like a bulletin system, use it like a forum.
When each subject takes his turn to make the next move, they consult a list of activities in the area, and add relevant ones to their priority queue. An area could be defined by the room they are in, as well as by a city, or maybe the proximity to the origin of the event. That way, you send one message to the board, and every agent reads the same set of messages.
When each subject takes his turn to make the next move, they consult a list of activities in the area, and add relevant ones to their priority queue. An area could be defined by the room they are in, as well as by a city, or maybe the proximity to the origin of the event. That way, you send one message to the board, and every agent reads the same set of messages.
Alright, I'd like to talk about something a bit more advanced.
The article that was linked to talks about overlapping activities. I wonder how that would work in practice.
Let's say a group of agents want to go hunting. The area is dangerous, so they want to provide escort for each other. They also want to share a vehicle, as the hunting ground is some way off.
So these could be the overlapping activities:
- Share vehicle
This activity means that agents will choose a vehicle, let everybody on or pick them up, decide who the driver is, and let people off at their respective destination or close to it.
- Move as a group
This activity means that the agents move from A to B together, along the same route and don't let people fall behind.
- Escort
This activity means that the agents provide protection for each other and defend rather than run away if they come under attack.
- Hunting
The agents cooperate on various hunting-related behaviour, tracking prey, collecting kill etc.
Along the way, additional activities may come up. Perhaps there is an emergency and one agent requires help from the others. And if it gets after dark, the agents might cooperate on making a camp site.
If it is really possible to divide cooperation tasks in this way, then it would be a huge benefit. The activities and their behaviour code could be combined across the whole spectrum of agent goals/actions without messing up their implementation. The question is how to do it in practice...?
The article that was linked to talks about overlapping activities. I wonder how that would work in practice.
Let's say a group of agents want to go hunting. The area is dangerous, so they want to provide escort for each other. They also want to share a vehicle, as the hunting ground is some way off.
So these could be the overlapping activities:
- Share vehicle
This activity means that agents will choose a vehicle, let everybody on or pick them up, decide who the driver is, and let people off at their respective destination or close to it.
- Move as a group
This activity means that the agents move from A to B together, along the same route and don't let people fall behind.
- Escort
This activity means that the agents provide protection for each other and defend rather than run away if they come under attack.
- Hunting
The agents cooperate on various hunting-related behaviour, tracking prey, collecting kill etc.
Along the way, additional activities may come up. Perhaps there is an emergency and one agent requires help from the others. And if it gets after dark, the agents might cooperate on making a camp site.
If it is really possible to divide cooperation tasks in this way, then it would be a huge benefit. The activities and their behaviour code could be combined across the whole spectrum of agent goals/actions without messing up their implementation. The question is how to do it in practice...?
I would set up an event.
When the hunters come across something that needs to be done, say, a campsite that needs to be made, they trigger the event. The event has a list of all the actions that need to be performed in order to complete the event, in this case, having a place to stay.
Then, the group leader (if your algorithm chooses a driver) or the group, (if it works more democratically) assigns the tasks to each person, rather than performing them as a group (unless the task requires multiple people, then create a new event for that task and dissect it in the same way).
When the hunters come across something that needs to be done, say, a campsite that needs to be made, they trigger the event. The event has a list of all the actions that need to be performed in order to complete the event, in this case, having a place to stay.
Then, the group leader (if your algorithm chooses a driver) or the group, (if it works more democratically) assigns the tasks to each person, rather than performing them as a group (unless the task requires multiple people, then create a new event for that task and dissect it in the same way).
Quote: I am not sure if I understand the advantage of the third option you suggest - perhaps you can explain it further...
It would be a bit like the bulletin board system, but each agent has it's own bulletin board.
EG: Agent (1) is doing the dishes. It sets a variable that other agents can access on it that is: Action = "Dishes".
Agent (2) comes along and currently has Action = "Get Mail".
Agent (2) sees Agent (1) and reads the variable "Action" from agent (1).
Agent[2].ReadAction(1) //agent 2 reads action from agent 1if (Agent[2].Action == "Idle") //as agent 2's action is not = idle then it will return false{ Agent[2].Action = Agent[3].ReadAction(1) //agent 2 never gets to this point}
As Agent (2) already has an action it would not change its action.
Then Agent (3) comes along and sees Agent (1). Agent (3) has no designated action so when it reads agent (1)'s action it then begins that action.
Agent[3].ReadAction(1) //agent 3 reads action from agent 1if (Agent[3].Action == "Idle") // as agent 3 is idle then this will return true{ Agent[3].Action = Agent[3].ReadAction(1) // this will change agent 3's action from idle to whatever agent 1 is doing}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement