Decentralised programming of communicating turtles - Semantic Scholar

4 downloads 0 Views 118KB Size Report
Keywords: micro-world, message passing, learning and agents. Introduction ... no-interaction; the entity is independent from others and only the surrounding environment .... For instance, a space shuttle may still be visiting one planet while the.
Decentralised programming of communicating turtles Giuseppina Capretti, Maria Rita Laganà and Laura Ricci Dipartimento di Informatica Corso Italia 40, 56125 Pisa ITALIA {capretti, lagana, ricci}@di.unipi.it Abstract In this paper we introduce a new agent-based programming language, Orespics PL, which allows users to represent the world in a decentralized way. Like other languages, Orespics-PL introduces the movement primitives of the Logo language and, for the first time, the constructs to exchange messages among turtles. Our system's world is populated by interacting entities able to synchronize and coordinate their actions using the message-passing paradigm. The entities are concurrent agents whose evolution is visible through the analysis of their movement on the screen.

Keywords: micro-world, message passing, learning and agents

Introduction Have you ever asked young people to play? All of them will be very enthusiastic and will surely accept. Have you ever asked young people to learn? It is not likely that you will hear enthusiastic comments. This is due to the fact that a game is something they very much like because it is interesting and it involves them deeply, while learning is often very boring and difficult for them. If we think of the mental process involved in the playing, we realise that it is similar to the one using in learning: a child has to analyse the game, understand its rules and apply and combine them to achieve her/his goal. For this reason, we think that if learning is concealed in a game, it is more involving for students. In this paper we present a new programming environment whose goal is to allow adolescents to learn a decentralised way of programming. We hope it is a new little Copernican revolution in the modification and evolution of the mental structures: we would like it to help young people to overcome the anthropocentric conception in favour of the decentralised one [Resnick M, 1990b]. In our system, several entities, which populate the virtual world and move in it, are able to simulate animal, human, social and imaginary behaviours and, for the first time, to communicate with each other consciously. The communication primitives allow the "real communication" simulation: to/from a single individual, to/from a set of similar individuals or to/from a set of non-homogeneous individuals.

The communication may require the acknowledgement of a sent/received message to continue the execution (receiver and sender have a strict rendezvous when the communication is synchronous) or not (in the case of asynchronous communication). The combining of these characteristics gives the possibility to achieve several interaction paradigms matching real situations: • • •

no-interaction; the entity is independent from others and only the surrounding environment influences its behaviour, centralised co-ordination or subordination; an entity organises the activities of a set of other entities, which do not interact with each other but only with the co-ordinator, co-ordination of the same level entities; a common task, subdivided among entities, is realised through their interaction and synchronisation.

Examples of real situations, corresponding to previous paradigms, are, for instance, a dog walking in a park (no-interaction), a manager organising the activities of its office (subordination), some people at the 3-7 game1 table (co-ordination of the same level entities).... In our system each entity may be considered as an agent and animated concurrent worlds may be programmed by an agent-based programming language [Travers 1992]. In our case the creatures are autonomous and have the ability to react to the outside stimuli. This paper is organised as follows: first we present an analysis of some existing proposals of decentralised systems, then we introduce our new system, Advanced Orespics and its Orespics-PL language and, finally, we show how to use it in the exploration of centralised and decentralised ways of thinking.

Related work Any programming environment designed to support the building of an animate system should offer some basic world-modelling capabilities and present them in an easy and accessible form. It must support the simultaneous animation of multiple objects. It must support object autonomy: i.e. objects should operate under their own control and must be able to sense the surrounding environment as well as interact with other animate objects. Several interesting proposals of animate system are known today. Multilogo [Resnick M, 1990a] is a programming language developed at M.I.T. by Mitchel Resnick. Its primary goal is to give users (children in particular) constructs for controlling multiple processes at once. Each process is an agent with its own procedure and its own variables, and is able to communicate with others by sending message. Each agent maintains a queue of expressions that it needs to evaluate. Each message is an expression to evaluate immediately or "whenever it gets a change": these two typologies of evaluation define how it is inserted in the queue of expressions. This language is used to define the behaviour of a robotic creature built with a computer-based construction system called LEGO-Logo. StarLogo [Resnick M, 1990b] is a programming environment to explore the behaviour of decentralised systems developed at M.I.T. Through this system, a student may program and control, in parallel, hundreds of turtles through a Logo-like programming language. The 1

A famous Italian game with Neapolitan cards

world of the turtles is alive: it is composed by hundreds of patches that may be considered like turtles that are programmable but without movement. Turtles move in parallel and use the patch to exchange messages. The main task of the system is the analysis and the simulation of decentralised systems of the world, in contrast to the more traditional models based on centralised systems: it helps users to realise that the individuals of a population may organise themselves without the presence of a centralised point of control. The LiveWord system [Travers M D, 1996] is a visual object-oriented programming environment that allows the research into agent-based programming techniques. A Liveworld's object is a named box and can contain other boxes as annotation. The LiveWorld's extension to Lisp includes a message passing language defined on boxes: when a box receives a message it looks for an annotation with the same name as the message. We feel that none of these systems allow a clear definition of communication among concurrent entities and none of these languages implement the communication primitives in a complete way. The Orespics system, developed at the Computer Science Department of the University of Pisa [Capretti G, 1997][Capretti G, Laganà M R and Ricci L, 1998] is programmable with Logo-PL, a local environment language in which students guide the action of, at most 8, virtual agents. The Logo-PL language is the first one to have explicit use of communication constructs. The prototype version implements basic primitives to send and receive messages. The receive primitive is synchronous and asymmetric while the send primitive is synchronous and symmetric. The introduction of these primitives allows students to subordinate the actions of certain creatures to the action of others [Capretti G, Cisternino A, Laganà M R and Ricci L, 1998]. As clearly shown, in this prototype, the set of the communication primitives is extremely poor.

The Advanced Orespics System Advanced Orespics is a project we are developing as a further improvement to the Orespics system described above. Its programming language is called Orespics-PL and is based on the local environment model and on the explicit use of the communication primitives. The Advanced Orespics system has substituted the previous one because a richer set of communication primitives is defined and no limit to the number of interacting actors in the world is imposed. Each actor is an agent of an animate system and has the attributes of autonomy, purposefulness and the ability to react to the surrounding environment according to the definition given in [Franklin S and Graesser A, 1996]: the interaction with the environment is achieved through messages passing. An agent is characterised by a set of properties: the initial position on the screen, its appearance and the code of its program. The system gives the users an interface with which to define all these properties. The system has a set of pre-defined fantastic and real characters like aliens and animals. The students may choose the most suitable character according to the situation to solve. The sequential part of Orespics-PL includes traditional imperative sequential constructs (repeat, while, if ...) and all turtle primitives of the Logo language [Papert S, 1980][Harvey

B, 1987]. Orespics-PL language offers all the elementary data types (integer, Boolean,...) and the list is the only data structure. Some of the operations defined on list type are getFirst(list), popEl(list, el), popFirst(list): getFirst returns the first item of list, popFirst pops the first element up; popEl pops up the el object from the list, if it is present, and no action is performed otherwise. We present some of the predefined functions and procedures used in the following examples: • versus(x, y) is the towards construct of Logo in [Harvey B, 1987] and returns the direction to assume in order to reach the point of co-ordinates x and y, • jump(x, y) is the setpos construct of Logo in [Harvey B, 1987] and the agent jumps to the point of co-ordinates (x, y), • random(val) returns a random value included in +/- val. If parameter is zero, it returns a random value according to the common definition. The behaviour of an agent is specified between the keyword Agent and end where the identifier following Agent defines its name. We now describe all the communication primitives of the language. As far as semantics is concerned, it is irrelevant that the communication partner is active, has finished the program execution, or is not ready to accept/receive the message. The syntax of the synchronous symmetric primitives is: send&wait msg to agent wait&receive var from agent In this case, when an agent sends/receives a message to/from another one and its partner is not ready for communication or is not active, it waits until the message has been received/sent [Hoare C A R, 1978]. The syntax of the asynchronous primitives is: no_wait&receive var from agent send&no_wait msg to agent An agent sends/receives a message to/from another one, but it does not wait for the successful issue of the communication. As for as concerns the send&no_wait primitive, the sender does not wait for the receiver to get the message and it goes on with its execution. If the receiver is not ready to accept it or it is not active, the message is inserted in a queue where messages are inserted and taken according to the order of arrival. We suppose that messages sent by one agent to another one are received in the same order as they are sent. As for as concerns the no_wait&receive primitive, the receiver checks the existence of incoming messages and goes on. If the queue is empty, the message has no meaning, and no value is assigned to the var. A particular function tests the meaning of the last message received. The receiver also performs a non-deterministic choice: it does not know, a priori, if the received message is valid. The syntax of the synchronous broadcast send is: sendAll&wait msg The syntax of the synchronous multicast send is: sendAll&wait msg to list_agents In the first case, an agent sends a message to all agents in the world while in the second case it sends a message only to the subset of agents defined in list_agents: in both cases it

waits for the successful issue of all the communications. Its execution is suspended until all the receivers get the message. Orespics-PL also defines asynchronous broadcast and multicast primitives: as regards the syntax, it is sufficient to substitute the word wait with no_wait and the semantics is analogous to the symmetric case. The language includes synchronous and asynchronous asymmetric receive. The syntax of the synchronous asymmetric receive is: wait&receiveAny msg from list_agents wait&receiveAny msg In the first case an agent receives a message from any of the active agents in list_agents, while in the second case, it receives a message from any active ones in the world, and, in both cases, it waits until at least one message has been received. If more than one message arrives, its selection is non-deterministic.

Centralised vs. Decentralised Interactions We now present how the Orespics environment may be used to experiment different ways to program the same problem in centralised and decentralised solutions. Each turtle is an agent: its graphical shape may be chosen among an extendible set of predefined characters. Let us consider this real situation: Two space shuttles are exploring of a new system of planets: each planet has to be visited by only one of them. We propose a sequence of different solutions characterised by an increasing level of decentralisation. A centralised solution The first solution defines a co-ordinator agent (the Head_Quarter agent) which divides the set of planets to be visited between the two agents. It may define a priori partition, or the tasks may be distributed dynamically, according to the agents’ workload. The program implementing the first strategy is as follow. Agent Head_Quarter ; partition (Planets, RedList, BlueList); send&no_wait RedList to Red_SpaceShuttle; send&no_wait BlueList to Blue_SpaceShuttle; end Agent Red_SpaceShuttle pencolour(ColourRed); pendown; wait&receive Planets from Head_Quarter; if (Planets nil) repeat visit_planet( getFirst(Planets)); popFirst(Planets); until (Planets = nil) endif end

The procedure visit_planet(obj) is implemented as follows: proc visit_planet (Planet) (x,y)

Suggest Documents