Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top