简体   繁体   English

Java中基于代理的建模-动画问题

[英]Agent-Based Modeling in Java - Animation Question

I'm creating an agent-based modeling program in Java. 我正在用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 我目前正在阅读本教程: http : //www.giosoft.net/Development/Java-Asteroids-Tutorial.html

It looks like it will help me with what I'm trying to accomplish. 看来它将帮助我完成我要完成的任务。

Between 2000-2006 I worked at Tryllian, a Dutch company specialized in multi-agent systems. 在2000年至2006年之间,我曾在Tryllian工作,这是一家专门从事多智能体系统的荷兰公司。 The company is non-active now. 该公司现在不活跃。

The first idea at Tryllian was to build an agent-based search appliance (called Gossip). Tryllian的第一个想法是构建基于代理的Search Appliance(称为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.). 背包可以包含一个搜索查询,以及多个搜索结果(URL,文档,图像等)。 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. 然后,该代理将被“传送”到Tryllian服务器,在该服务器上,驻留在服务器上的“管家-代理”将其定向到“主题室”。 In the room it could interact with other agents and exchange search interests and -results. 在会议室中,它可以与其他代理进行交互并交换搜索兴趣和结果。 It looks like you can still download Gossip here . 看来您仍然可以在这里下载Gossip。

这是八卦客户端的外观

Later Tryllian decided to develop an Agent Development Kit (ADK) with which one could create agent applications like Gossip more easily. 后来,Tryllian决定开发一种Agent Development Kit(ADK),利用它可以更轻松地创建Gossip之类的Agent应用程序。 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). 您的代理将获得很多事件(agentStarted等),并且在事件处理程序中可以添加任务,而任务又会获得事件(taskStarted等)并可以安排更复杂的行为(可能以子任务的形式)。 The API was really quite nicely done. 该API确实做得很好。

The key feature of the ADK was in my opinion the code mobility it offered; 我认为ADK的主要功能是它提供的代码移动性。 not only could agents travel between virtual rooms on their local ARE (Agent Runtime Environment), but could also travel to another server. 代理不仅可以在其本地ARE(代理运行时环境)上的虚拟房间之间旅行,而且还可以旅行到另一台服务器。 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. 例如,Tryllian开发了一个远程审核应用程序,该应用程序允许审核公司的分析人员将审核规则编码为代理,然后将其安全地发送到其客户的服务器以监视流程。

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. Tryllian代理模型更侧重于消息传递,而不是与模拟物理环境的紧密交互。 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. 您不会利用Tryllian代理的强项:代码移动性,基于任务的编程,通用性,因此我认为它不是进行此类仿真的最佳工具。

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! 祝好运并玩得开心点!

You might want to take a look at MASON . 您可能想看看MASON It's an open-source Java platform for multi-agent simulation. 这是一个用于多主体仿真的开源Java平台。 Some of the demos (eg MAV) show how to do exactly what you describe. 一些演示(例如MAV)演示了如何完全按照您的描述进行操作。

RePast is another Java platform that might be an option. RePast是另一个Java平台,可以选择。

Finally, NetLogo makes what you describe extremely easy. 最后, NetLogo使您的描述变得极为简单。 Though it's possible to integrate NetLogo with other Java code, it has it's own little language that allow very rapid development. 尽管可以将NetLogo与其他Java代码集成在一起,但是它具有自己的少量语言,可以非常快速地进行开发。

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. 您可能会进行2维或3维可视化。 You might want to use toroidal space. 您可能要使用环形空间。 You might impose a grid (eg discrete x and y dimensions) or you might allow for continuous space. 您可以施加网格(例如,离散的x和y尺寸),也可以允许连续的空间。 You might have certain rules about proximity (eg 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?" “我应该考虑哪些基于Java的动画库?”

    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. 这是一个广泛的主题,但是我建议您看一下Processing,Piccolo2D,JavaFX,Java 2D和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. 基于代理的模型可以由GUI和/或命令行界面驱动。 If you want a GUI, you are going to want various input controls so that model parameters can be tuned. 如果需要GUI,则需要各种输入控件,以便可以调整模型参数。 You'll want to consider, at least, Swing and JavaFX. 您至少要考虑Swing和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. 到目前为止, 基于代理的建模工具Wikipedia比较是我迄今为止看到的最全面的列表,但它可能会让您不知所措。 In my experience, coworkers and peers tend to gravitate to one or more of the following: NetLogo, RePast Simphony, AnyLogic, or MASON. 根据我的经验,同事和同事倾向于使用以下一种或多种:NetLogo,RePast Simphony,AnyLogic或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. 如果您走这条路,我强烈建议您看一下Ruby,Scala或Python之类的高级语言,以使自己专注于域逻辑而不是低级语言细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM