# 3APL

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/3APL
> Markdown URL: https://mediated.wiki/source/3APL.md
> Source: https://en.wikipedia.org/wiki/3APL
> Source revision: 1288904597
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Experimental tool and programming language}}
'''An Abstract Agent Programming Language''' or '''Artificial Autonomous Agents Programming Language''' or '''3APL''' (pronounced triple-A-P-L) is an experimental [tool](/source/tool) and [programming language](/source/programming_language) for the development, implementation and testing of multiple [cognitive](/source/cognitive) [agent](/source/software_agent)s using the [Belief-Desire-Intention](/source/BDI_software_agent) (BDI) approach. 

==Overview==
3APL was developed and is maintained by a team at the [computer science](/source/computer_science) department of [Utrecht University](/source/Utrecht_University) in the [Netherlands](/source/Netherlands). It facilitates specification of cognitive agent behavior using actions, beliefs, goals, plans, and rules. It has been subject to at least 15 [paper](/source/scientific_paper)s and [conference](/source/academic_conference)s, and at least 4 [theses](/source/thesis).

==Platform==
The 3APL [platform](/source/computer_platform) has a visual interface for the monitoring and [debug](/source/debug)ging of agents being run therein, and a [syntax](/source/syntax)-coloring [editor](/source/text_editor) for [source code](/source/source_code) editing. It has been released as a [Java](/source/Java_(programming_language))-based [software](/source/software), which comes with some specification Java [interface](/source/interface_(java))s that can be used to develop Java-based [plug-in](/source/plug-in_(computing))s and [libraries](/source/library_(computer_science)). These can be used to provide a visible representation of a virtual environment, for instance. A 3APL platform can also connect in [client](/source/client_(computing)) or [server](/source/server_(computing)) roles to other 3APL platforms across a [network](/source/computer_networking), to allow [communication](/source/communication) among 3APL agents on each platform. A lightweight version of 3APL for [mobile application](/source/mobile_application)s, named [3APL-M](/source/3APL-M) "[Toymaker](/source/Toymaker_(software))", has also been released.

==Language==
The 3APL language is relatively simple. The syntax has basic [boolean](/source/boolean_logic) [logical operator](/source/logical_operator)s [AND](/source/logical_conjunction), [OR](/source/logical_disjunction) and [NOT](/source/logical_negation), with IF-THEN-ELSE [conditional statement](/source/Conditional_(programming))s, and WHILE-DO [control flow](/source/control_flow) loop structures. While temporary [variables](/source/Variable_(programming)) cannot be created except by calling plug-in methods or belief/goal conditions, [iterative](/source/iteration) counter loops can be constructed using a combination of WHILE-DO loops, beliefs and capabilities.

A 3APL agent contains formal definitions of agent beliefs, capabilities, goals and plans. Specifically, there are six skeletal blocks that must be defined.

<pre>
PROGRAM "agent"
BELIEFBASE {}
CAPABILITIES {}
GOALBASE {}
PLANBASE {}
PG-RULES {}
PR-RULES {}
</pre>

The beliefs, defined using [Prolog](/source/Prolog) syntax, are used to remember information and to perform logical [computation](/source/computation)s. Beliefs can be read by one another, edited by the capabilities, and read by conditional statements in the plans. The initial beliefs of an agent can be defined in its belief base.

<pre>
BELIEFBASE {
	status(standby).
	at(0,0).
	location(r1,2,4).
	location(r5,6,1).
	dirty(r1).
	dirty(r5).
}
</pre>

Capabilities define the prerequisites and effects of actions in a [STRIPS](/source/Stanford_Research_Institute_Problem_Solver)-like format, reading preexisting beliefs, removing some using the NOT operator, and adding new ones by stating them.

<pre>
CAPABILITIES {
	{status(S1)} SetStatus(S2) {NOT status(S1), status(S2)},
	{at(X1,Y1)} NowAt(X2,Y2) {NOT at(X1,Y1), at(X2,Y2)},
	{dirty(R)} Clean(R) {NOT dirty(R)}
}
</pre>

Goals are also defined using Prolog syntax, and new goals can be adopted during runtime. Initial goals are defined in the goal base.

<pre>
GOALBASE {
	cleanRoom(r1).
	cleanRoom(r5).
}
</pre>

Each goal ideally has associated goal planning rules, its PG rules, which serve as an abstract plans and are called from the goals as long as their guard conditions are met.

<pre>
PG-RULES {
	cleanRoom(R) <- dirty(R) | {
		SetStatus(cleaning(R));
		goTo(R);
		clean(R);
		SetStatus(standby);
	}
}
</pre>

The PG rules in turn can call plan revision rules, or PR rules, which serve as subroutines, and can be called upon to execute lower level and/or repetitive tasks as long as their guard conditions are met. Initial plans are defined in the plan base, executed at the beginning of the [deliberation](/source/deliberation) cycle.

<pre>
PLANBASE { SetStatus(started); }
PR-RULES {
	goTo(R) <- location(R,X,Y) AND NOT at(X,Y) | {
		NowAt(X,Y);
	}
	clean(R) <- location(R,X,Y) AND at(X,Y) | {
		Clean(R);
	}
}
</pre>

External methods may be called to access the environments modeled in the plug-ins. However, [parameter](/source/parameter)s cannot be directly passed to the methods, which means that the known environment must be correspondingly modeled in the agent's beliefs. The call returns a Prolog list, which can then be processed by the agent's own [predicate logic](/source/predicate_logic).

<pre>
Java("JanitorWorld", moveNorth(), M);
</pre>

Agents can also communicate with one another using ''Send'' commands. When a piece of information X is sent with the performative P from agent A to agent B, the sending action is recorded in A's belief base as ''sent(B,P,X)'' and is registered in B's belief base as ''received(A,P,X)''.

<pre>
Send(Partner,inform,dirty(R));
</pre>

==Download==
3APL is available for [download](/source/download) at the University of Utrecht's 3APL website, packaged with sample lone and communicative agents, and a [discrete](/source/discrete_space) multi-agent foreground environment plug-in called [BlockWorld](/source/BlockWorld).

==See also==
* [Autonomous agent](/source/Autonomous_agent)
* [Cognitive architecture](/source/Cognitive_architecture)
* [Agent communication language](/source/Agent_communication_language)

==Further reading==
* [http://www.cs.uu.nl/3apl/download/java/userguide.pdf 3APL User Guide for Java version] {{Webarchive|url=https://web.archive.org/web/20170329171122/http://www.cs.uu.nl/3apl/download/java/userguide.pdf|date=2017-03-29}}
* [http://www.cs.uu.nl/3apl/deliberationcycle.pdf 3APL deliberation cycle] {{Webarchive|url=https://web.archive.org/web/20130619054513/http://www.cs.uu.nl/3apl/deliberationcycle.pdf|date=2013-06-19}}

==External links==
* [http://www.cs.uu.nl/3apl/ 3APL Homepage]

Category:Agent-based programming languages

---
Adapted from the Wikipedia article [3APL](https://en.wikipedia.org/wiki/3APL) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/3APL?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
