A Hierarchical State Machine using JADE Behaviours with Animation Visualization Robert Kessler Martin Griss Brian Remick Ryan Delucchi School of Computing Computer Science School of Computing Associate of Martin Griss University of Utah University of California, Santa Cruz University of Utah Independent Contributor Salt Lake City, UT 84112 1156 High Street Salt Lake City, UT 84112 350 Bean Creek Rd. Santa Cruz, CA 95064 Scotts Valley, CA 95066 kessler@cs.utah.edu griss@soe.ucsc.edu remick@cs.utah.edu scate@metaforte.com Abstract In previous papers [5], [6] we describe an event-based UML state machine execution engine as well as a Micro- soft Visio-based visual editor that has many benefits over the built-in JADE FSM (Finite State Machine) behaviour model. These benefits are an integration of message han- dling, timeouts, exceptions and the use of hierarchy and common action factoring to reduce the complexity of be- haviour construction, while ultimately improving system scalability. In that work we engineered a consistent, largely self-contained component, with several key properties, but relatively incomplete integration with other JADE behav- iour mechanisms. Since then, we have developed a new Hierarchical State Machine (HSM) model that shares many of the same goals of reducing the complexity of developing protocols and behaviours, but is a vastly improved companion to JADE. It leverages the newer JADE Composite Behaviour and offers substantial improvements over the JADE FSM. Furthermore, we describe a new Java based graphical tool that facilitates designing, visualizing, and reverse engi- neering of HSMs. Finally, we describe one of several sys- tems that have been built using HSM. 1. Introduction In previous work [4], [7], and [6], we built several dif- ferent multi-agent systems using ZEUS [9] and JADE [2]. We found that once you began to have agent-to-agent con- versations and protocols that were more than simple mes- sage exchanges, a state machine model was well-suited for managing the interaction. As have others (such as AUML [10]) we began examining state machine models and looked toward the UML State Machine. The UML state machine [3] evolved from the hierarchical statechart work of Harel [8]. A UML state machine defines states and tran- sitions that connect states. Hierarchy appears because states and machines can be built within other states and machines. This hierarchal processing of elements makes it easier to describe complex conditions and transitions. As we built more comprehensive agents, we found that we needed ways to handle common default conditions and exceptional situations. Hierarchy was a perfect solution as it permits factoring common code, allowing more natural and concise expression. UML state machines are event driven; actions come in the form of events that are presented to the state machine, typically driving transitions. The UML state machine is very powerful, allowing the implementation of both Mealy and Moore styles of state machine. That is, activities of the state machine can be ex- pressed as an action within the state itself or expressed as an action on the state transition. One can also mix and match this style depending on the problem at hand, leading to the concise, understandable and maintainable machines. Given that the behaviour models already in JADE were either too simple (the FSMBehaviour model essen- tially only permits flat state machines) or not easy to map into, we created our original Hierarchical State Machine model with Microsoft Visio as the drawing tool. This sys- tem gave us all of the benefits of hierarchy and common action factoring, but failed to integrate sufficiently with JADE. It forced the agent author to mix traditional JADE behaviours with straight Java HSM code which often caused thorny coordination problems. ____________ Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, or republish, to post on servers or to redistribute to lists, re- quires prior specific permission and/or a fee. AAMAS ’04,….. Recognizing the FSMBehaviour benefit of allowing any behaviour to be a state, we embarked on a project to create a new version of HSM that kept the full power of 1