2

I'm creating an agent-based modeling program in Java.

I'm trying to determine the best way to animate the agents. I've seen several examples that use a grid, allowing each agent to occupy only one cell at a time.

I'm looking for something smoother, where agents can "flow" across the window in all directions.

Any suggestions?

Thanks!

Edit:

The environment will be simple and two-dimensional. There will be anywhere from one agent to several hundred agents.

I'd like to represent the agents as small circles with some sort of indication of direction (the specifics are irrelevant; the point is that the agent needs the ability to rotate).

Second edit:

I'm currently reading this tutorial: http://www.giosoft.net/Development/Java-Asteroids-Tutorial.html

It looks like it will help me with what I'm trying to accomplish.

Peter
  • 4,021
  • 5
  • 37
  • 58
  • There are many spatial data strcutures. We can't tell which ones would be right for you without knowing your requirements. For instance, how do agents interact with each other / the environment? How can you describe the environment to make that simple? – meriton Sep 11 '11 at 07:29
  • Edited to add details. Thanks. – Peter Sep 11 '11 at 07:52
  • Here's an example of something similar. http://www.xjtek.com/models/?archive=pedestrian_models/pedestrian_library_test_suite/model.jar,EnterpriseLibrary.jar,PedestrianLibrary.jar,xjanylogic6engine.jar,xjanylogic6engine_ru.jar&root=pedestrian_library_test_suite/Simulation$Applet.class&width=802&height=658&version=6 – Peter Sep 11 '11 at 07:59

3 Answers3

2

Between 2000-2006 I worked at Tryllian, a Dutch company specialized in multi-agent systems. The company is non-active now.

The first idea at Tryllian was to build an agent-based search appliance (called Gossip). This had a graphical client app with a number of brightly colored circular agents with cute eyes. Each agent had a gap in its back in which a 'backpack' could be dragged. The backpack could contain a search query, and a number of search results (URL's, documents, images etc.). To do a search the user had to drag an agent with a prepared backpack onto the 'portal to the Internet' which was a kind of landing bay door with a starry background as you see in sci-fi movies. The agent would then be 'teleported' to the Tryllian server where it would be directed to a 'topic-room' by a 'butler-agent' which lived on the server. In the room it could interact with other agents and exchange search interests and -results. It looks like you can still download Gossip here.

Here's what the Gossip client looked like

Later Tryllian decided to develop an Agent Development Kit (ADK) with which one could create agent applications like Gossip more easily. It offered a task-based model for programming agent behavior. Your agent would get a lot of events (agentStarted etc) and in the event handlers could add tasks which in turn also would get events (taskStarted etc) and could schedule more complex behaviors (possibly in the form of subtasks). The API was really quite nicely done.

The key feature of the ADK was in my opinion the code mobility it offered; not only could agents travel between virtual rooms on their local ARE (Agent Runtime Environment), but could also travel to another server. This involved class serialization and a multi-classloader solution which was quite revolutionary at the time (we liked to think). This feature enabled designs where you bring the code to the data instead of having to pass data around (pumping data around is still a main feature of most enterprise systems I know of). For instance Tryllian developed a remote auditing application which allowed analists from the auditing company to encode auditing rules into an agent and send it securely to their client's server to monitor processes.

I'll stop before this answer starts getting really long (-;

This is probably all a bit more than what you are looking to achieve right now. If you can formulate your questions a bit more specifically I could give some advise on how to set up your multi-agent system (how to model messaging between agents is also a very intersting topic btw - oh sorry, I said I'd stop...).

What would your multi-agent system's purpose be? What would an agent do? Would it run on one machine, or distributed? Would agents be hardcoded, configurable or completely dynamic in their behavior/rules?

One last suggestion: A reasonable starting point for thinking about modelling simple agents is sense-plan-act which is usually associated with robots.

EDIT: response to your comment

The Tryllian agent model is focussed more on messaging than on tight interaction with a simulated physical environment. Looking at the example site you posted it seems like performance is pretty crucial especially when the number of agents rises. You would not be exploiting the Tryllian agent's strong points: code mobility, task-based programming, genericity, so I think it would not be the best tool for a simulation like this.

You mention a 'grid' versus a 'smooth' approach. I think in a computer simulation you will always need to represent the agents' size, coordinates, speed and direction withinin some sort of discrete system of coordinates. There wil thus always be some sort of grid, but you can make the 'cells' smaller to make it seem smoother.

Maybe there are some useful resources to be found in the gaming domain? (sprites, collision detection etc.)

Good luck and have fun!

Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60
  • Very informative response. Could you add some particulars about animation? You can see an example of something similar to what I'm trying to accomplish. It's in my most recent comment on my original question. Thanks! – Peter Sep 11 '11 at 20:25
  • Multi-Agent Systems have a significantly different emphasis from Agent-Based Modeling. It seems as though your answer is focused on the former, but @Peter is interested in the latter. – David J. Sep 13 '11 at 00:06
  • This response does not address the question. – David J. Sep 13 '11 at 00:13
  • @David You are right. I realised this after Peter added his comment with the link to http://www.xjtek.com. I guess I got a little bit carried away there (-: Still Peter is now reading a tutoria about the Asteroids game, so I guess my final suggestion might still be helpful. – Adriaan Koster Sep 13 '11 at 09:33
  • @Adriann Though perhaps this is not the right forum, I would like to learn more about potential similarities and differences between Agent Based Modeling and Multi Agent Systems. – David J. Sep 17 '11 at 00:44
2

You might want to take a look at MASON. It's an open-source Java platform for multi-agent simulation. Some of the demos (e.g. MAV) show how to do exactly what you describe.

RePast is another Java platform that might be an option.

Finally, NetLogo makes what you describe extremely easy. Though it's possible to integrate NetLogo with other Java code, it has it's own little language that allow very rapid development.

Nicolas Payette
  • 14,847
  • 1
  • 27
  • 37
  • I downloaded RePast but found it too bloated. This Keep-Away demo from MASON (which I'd briefly investigated) seems to contain a lot of the features I'll need. Thanks! – Peter Sep 12 '11 at 04:56
1

I can't tell what you are really asking. Perhaps you are asking (or meant to ask) these three questions?

  1. "For my agent-based model, how should I represent my agents in space?"

    When doing agent-based modeling, you have to design your simulation in way that makes sense for your domain. No one here can give you a reasonable answer as to what spatial choices to make unless they have some idea about your domain.

    You might go with 2 or 3 dimensional visualization. You might want to use toroidal space. You might impose a grid (e.g. discrete x and y dimensions) or you might allow for continuous space. You might have certain rules about proximity (e.g. only one agent can occupy one grid space at a time). You might want to go with some other set of rules.

    Again, the key is to find a set of rules that makes sense for your domain. I would recommend finding the simplest set of rules that still create the kinds of behavior essential to your model.

  2. "What Java-based animation libraries should I consider?"

    Once you have decided the spatial aspects of your agent-based model, then you will be ready to decide what technologies to use to display it. This is a broad topic, but I would recommend that you take a look at Processing, Piccolo2D, JavaFX, Java 2D, and Java 3D.

    Actually, This question is a little broader than I stated it above. You probably are going to care about more than just animation. Agent-based models may be driven by GUIs and/or command line interfaces. If you want a GUI, you are going to want various input controls so that model parameters can be tuned. You'll want to consider, at least, Swing and JavaFX.

  3. "What toolkits or libraries should I use to help me build my agent based model?"

    The Wikipedia comparison of agent-based modeling tools is the most comprehensive list I've seen so far, but it may overwhelm you. In my experience, coworkers and peers tend to gravitate to one or more of the following: NetLogo, RePast Simphony, AnyLogic, or MASON. Some people (including myself) often find it faster to roll-your own. If you go that route, I highly recommend that you take a look at high level languages like Ruby, Scala, or Python to allow yourself to focus on the domain logic instead of the low level language details.

David J.
  • 31,569
  • 22
  • 122
  • 174
  • Thanks for the response. I'm looking to create a two-dimensional environment without the use of grid cells (at least, without the *apparent* use of grid cells). The asteroids example I posted showcases smooth animation with omnidirectional movement. I've worked with Java somewhat extensively (albeit, never animation), and I know how to create a GUI. Additionally, I've downloaded RePast and I'm currently looking through some related tutorials so I can see how things are done. Not wanting the ~70mb models generated by RePast, however, has led me to attempt to roll my own solution. – Peter Sep 13 '11 at 05:56
  • 1
    Hi Peter, given that you have Java experience, I think you'll do fine by rolling your own. Just steal the concepts from the ABM frameworks you find useful. Personally, I'm heavily influenced by the Rails approach: build a bunch of applications that fit your needs -- and only after you discover a pattern should a framework be extracted. I also have found RePast to be a bit obtuse to ramp up on. That said, building and communicating a framework is not easy. I think the ABM world should keep thinking about this challenge. – David J. Sep 17 '11 at 00:41