# Example Programs

# Making Agents Mobile

This is not intended to be a serious attempt to implement mobile agents, but is a quick sketch of how it could be done quickly in ASTRA… The code below …

# Bully Election Algorithm

The Bully Election algorithm is a well known algorithm created by Garcia-Molina in 1982 that is aimed at providing a decentralised algorithm for electing a leader amongst a set of peers. …

# Token Ring Implementation

This benchmark appears in [1]. The basic idea of the benchmark is to test the performance of the message passing infrastructure by creating a token ring containing WT worker agents, …

# Revised Pipeline Code

We now try to reconstruct our basic pipeline model using the generalised roles presented above. We will need to give these agents different names, so lets prefix each agent class …

# The Core Behaviours

In this section, we identify the core behaviours and encapsulate them in one or more agent classes. The Generator If we reflect on the Generator implementation in the previous section, …

# A Basic Pipeline

To get us started, we will first examine a basic pipeline example as is illustrated in the figure below. In this model, the three worker agents form a pipeline. The …

# Introduction

This program is a simple but fun illustration of a production line type of problem, where three worker agents are given specific tasks to perform in a sequence: Generator: responsible …

# The Iterative Version

Last, but not least, we introduce a standard iterative solution. This example, would normally be one of the first discussed for a procedural language, but here, we have left it …

# A Partial Plan-based Solution

Partial plans are an alternative to plan rules. The do a similar thing to goal rules, with the exception that no event is generated, and no rule matching takes place. …

# A Better Recursive Solution

A better approach is to use recursion where you generate the numbers in their natural order. this makes the code look a little less elegant, but it does result in …

# The Recursive Solution

This second program uses recursive subgoals to generate the fibonacci number. The intuitive idea when implementing a recursive solution is, for fib(i), to recursively generate fib(i-1) and fib(i-2). This would …

# The Classical Solution

This version of the Fibonacci Number Generator is viewed as the “classic” version because it can be implemented in basic AgentSpeak(L), while the other versions cannot. package examples.fibonnacci; agent Fib …

# Introduction

Fibonacci Numbers are numbers in the sequence: 1, 1, 2, 3, 5, 8, 13, … Each number is generated by adding together the two previous number in the sequence, with …