Skip to content

ssardina-agts/agtcity-sarl-base

Repository files navigation

SARL Controller for Agents in the City 2018+ - BASE

This project/package provides basic SARL controllers for the MAC Agents in City Contest.

This version supports the RMIT 2018+ edition of the Agents in City Game, which is basically the official 2018 edition with items brought back to shops.

It can be used as an initial set-up to build more advanced controllers.

PREREQUISITES

The following needs to be installed system-wide:

  • Java SE Development Kit (JDK) Version 1.8+.
  • Maven project management and comprehension tool (to meet dependencies, compile, package, run).
  • The RMIT 2018+ game server edition: An enhanced edition of the official 2018 version that brings back items to shop as in the 2017 version.
  • SWI-Prolog: a state-of-the-art implementation of Prolog.
  • JPL package for SWI-Prolog: Java classes and C native functions providing a bidirectional interface between Java and Prolog.

The following dependencies are resolved via Maven and JitPack automatically:

VERSION MANAGEMENT

The version convention used is Major.Minor.Patch. Each version will rely on a particular SARL version:

  • 4.5.10: SARL 0.11.0
  • 4.5.0.11.0: SARL 0.11.0

The SARL version is dictated by <sarl.version> property in the POM file.

DESCRIPTION OF DUMMY AGENTS

INSTALL, RUN and DEVELOP

Three simple dummy controllers are provided as examples via the following agents:

  • SuperSingleAgent: fully implemented in SARL/Java.
  • SWISuperSingleAgent: implemented using SARL/Java and SWI-Prolog.
  • BootMultiSWIAgents: spawns two SWISuperSingleAgent agents, each managing two entities.

Details of each system in the next section.

You can use the source JAR files for modules EIS and massim provided in extras/ to attach sources in ECLIPSE (their sources are not available via Maven).

So, to run the system you need to follow these general steps:

  1. Compile the base system: mvn clean package

  2. Start RMIT 2018+ Game Server. From server/ folder:

    $ ./startServer.sh conf/SampleConfig.json

    or run it using Java itself:

    $ java -jar target/server-2020-1.0-jar-with-dependencies.jar --monitor 8001 -conf conf/SampleConfig.json

    Note that the configuration file (here, conf/SampleConfig.json) makes a reference to the team configuration file at the bottom (e.g., conf/teams/A.json) which is the file containing all agents allowed to connect and with which id and password. These are the ones your system will use in your agent configuration file.

    In the console of the server, you will see a URL link to the monitor. Click it to see the GUI interface of the game.

  3. Start the SARL Controller, either via ECLIPSE or through the CLI. Remember the application needs the JSON server connection configuration file eismassimconfig.json. For example:

    $ mvn exec:java -Dexec.args="SuperSingleAgent conf/SingleAgent" -Dloglevel=4

    NOTE: If you run mvn exec:java without arguments, it will list all available controllers and ask for one, and then also ask for location of server connection configuration file eismassimconfig.json.

    One can also start an agent directly via Java as follows:

    $ java -jar target/agtcity-sarl-base-4.5.0.11.0-jar-with-dependencies.jar io.sarl.sre.boot.Boot SuperSingleAgent -Dloglevel=4
  4. Start the MASSIM Simulation by just hitting ENTER in the Game Server console.

  5. Enjoy! You should start seeing the agent reporting things in the console. You can see the simulation on the web browser.

You can use grep inverse -e to get rid of all the printout of XML messages produced by the EI framework (filter out everything between < >, and any "sent" and "received" printout at start of line):

$ mvn exec:java | grep -v -e  \<.*\> -e WARNING -e '^ sent' -e '^ received'

Developing SARL agents

Package au.edu.rmit.agtgrp.agtcity.sarl.agents.dummy contains some simple examples that could be used as a base for your own new development. In particular, it has all the connectivity/communication with the game server already resolved, as well as a simple sensing cycle.

As the system becomes very complex, it may be convenient to use a better technology than Java data-structures to do belief maintenance and reasoning. One possibility is to use Prolog knowledge-bases, by making use of SWI-Prolog via the JPL-based skill SWIJPL_KB_Prolog in the SARL-PROLOG-CAP framework. Some initial code for a domain knowledge base is already provided in agent SWISingleFullAgent, including substantial Prolog code to process percepts.

Three simple example SARL agent controllers are provided in this base system as a reference. These examples should provide a solid base for developing more sophisticated agent systems for Agents in City.

All the agents can be run via the booting class BootMAS, which is the default execution class in the package JAR file and when running mvn exec:java; see above. If one defines another booting class, e.g.. BootMAS2, it can be used using:

$ mvn exec:java -Dexec.mainClass=BootMAS2

To change the log level, pass -Dloglevel=n option (FINE/DEBUG=4; INFO=3; WARNING=2; ERROR=1). Defaults to level 3.

The agents can be given a parameter as an object of class au.edu.rmit.agtgrp.agtcity.sarl.utils.BootingConf which can store various settings to be used when booting the agent.

SuperSingleAgent: The SARL controller

Package: au.edu.rmit.agtgrp.agtcity.sarl.agents.dummy.SuperSingleAgent

A simple centralized agent that controls many entities in the MW. It can be started via:

$ mvn exec:java -Dexec.args="SuperSingleAgent conf/SingleAgent"

This SARL agent will first register a set of entities to be controlled. Then it will repetitively perceptive percepts for each entity, update a global its global view of the game (by updating a MW's State object), and make all entities navigate to random shops.

To tell the SARL agent which entities to control among the available:

$ mvn -o exec:java -Dexec.args="SuperSingleAgent conf/SingleAgent entityA1 entityA2 entityA3" 

SWISuperSingleAgent: The SWI-based controller

Package: au.edu.rmit.agtgrp.agtcity.sarl.agents.dummy.SWISingleFullAgent

This is a similar system as SWISuperSingleAgent but uses Prolog Knowledge Base (KB) via the JPL-based SWI_KB_AgtCity skill.

To help understand the Prolog KB, the SARL agent prints out, at every sensing cycle, some results from queries and then dumps its entire KB into a file with the step number as part of the file name.

The agent contains a few example uses of how to assert in the KB and query it. It also contains simple logic to continuously select a random destination and go there.

This agent can be run directly as follows:

$ mvn -o exec:java -Dexec.args="SWISuperSingleAgent conf/SingleAgent"

BootMultiSWIAgents: The Multi-agent Controller

This is a multi SARL agent system based on a set of SWISuperSingleAgent SARL agents. Each of these agents spawn is in charge of controlling a set of entities in the game simulation (or even just one entity).

The SARL agent BootMultiSWIAgents is booted first, which in turn will spawn SWISuperSingleAgent SARL agents. It will override its default initial values to provide authentication files directly as arguments to the initialization.

Here is how we can start this system directly:

$ mvn -o exec:java -Dexec.args="BootMultiSWIAgents conf/SingleAgent"

This agent has the different teams hard-coded, so any other argument passed (list of entities to be controlled) will be ignored. The different teams will have a different object BootingConf, each containing a different set of entities to control.


PROJECT CONTRIBUTORS

  • Sebastian Sardina (Project leader and contact - ssardina@gmail.com)
  • Matthew McNally (ex-RMIT student; first version of SWI-based agent via the deprecated Mochalog interface)
  • Joshua Hansen (ex-RMIT student)
  • Adam Young (ex-RMIT student)

LICENSE

This project is using the GPLv3 for open source licensing for information and the license visit GNU website (https://www.gnu.org/licenses/gpl-3.0.en.html).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

About

A SARL base controller for Agents in City 2018+

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages