⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swarm.overview.mag4.define-agent.sect1.html

📁 set for Swarm2.1是圣菲研究院的开发人员对Swarm的特性及其使用描述的最为完备的指南性文档。从这里可以获得最细致的平台说明。
💻 HTML
字号:
<HTML><HEAD><TITLE>Defining an Agent</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.53"><LINKREL="HOME"TITLE="Documentation Set for Swarm 2.1.1"HREF="set.html"><LINKREL="UP"TITLE="Mag 4x:Sketch of Code "HREF="swarm.overview.mag4.chapter.html"><LINKREL="PREVIOUS"TITLE="Mag 4x:Sketch of Code "HREF="swarm.overview.mag4.chapter.html"><LINKREL="NEXT"TITLE="Building Agents"HREF="swarm.overview.mag4.build-agents.sect1.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Documentation Set for Swarm 2.1.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="swarm.overview.mag4.chapter.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 4. Mag 4x:Sketch of Code</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="swarm.overview.mag4.build-agents.sect1.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.OVERVIEW.MAG4.DEFINE-AGENT.SECT1">4.2. Defining an Agent</A></H1><P>The agents are typically the real focus of a modeling    effort. Most of the work in a simulation comes in defining the    agent behavior so that the computer agents resemble the real world    phenomena you are trying to create.</P><P>In the case of Heatbugs, agents are pretty simple. Here is    their definition, from Heatbug.h:</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">      @interface Heatbug: SwarmObject { double unhappiness; // my current unhappiness int x, y; // my spatial coordinates HeatValue idealTemperature; // my ideal temperature HeatValue outputHeat; // how much heat I put out float randomMoveProbability; // chance of moving randomly Grid2d * world; // the world I live in int worldXSize, worldYSize; // how big that world is HeatSpace * heat; // the heat for the world Color bugColor; // my colour (display)}-setWorld: (Grid2d *) w Heat: (HeatSpace *) h; // which world are we in?-createEnd;-(double) getUnhappiness;-setIdealTemperature: (HeatValue) i;-setOutputHeat: (HeatValue) o;-setRandomMoveProbability: (float) p;-setX: (int) x Y: (int) y; // bug's position-setBugColor: (Color) c; // bug's colour (display)-step;-drawSelfOn: (id &lt;Raster&gt;) r;&#13;</PRE></TD></TR></TABLE><P>Heatbug is a subclass of SwarmObject. SwarmObjects have very    little behavior of their own - they are defined as the root class    of most objects and control computer science aspects like memory    allocation and probability.</P><P>Heatbug carry with them a variety of state variables. For    instance, each Heatbug has a notion of its ideal temperature,    which will affect it's behavior. In addition, Heatbugs have    variables that let them know about the world: these agents are    storing references to the HeatSpace object, for example.</P><P> Most of the Heatbug methods have to do with setting up the    agents state - the inputs to a Heatbug. Every heatbug must set up    its world and heat objects, via the    <TTCLASS="LITERAL">setWorld:Heat:</TT> method. In addition when    Heatbugs are created they have their ideal temperature set, their    output heat, etc.  Heatbugs are also observable. Heatbugs define a    <TTCLASS="LITERAL">getUnhappiness</TT> method - the unhappiness is the    major measurable aspect of a heatbug, how well optimized it is at    the moment. They also have a <TTCLASS="LITERAL">drawSelfOn</TT> method    that directs the heatbug to draw itself on the specified graphics    widget.</P><P>Finally, and most importantly, a Heatbug has a    <TTCLASS="LITERAL">step</TT> method.  <TTCLASS="LITERAL">step</TT> is where    the Heatbugs behavior is defined: every time the Heatbug is told    to step it performs its internal calculations, choosing where to    move. Each heatbug is told to <TTCLASS="LITERAL">step</TT> when    appropriate by the model schedule. The code for    <TTCLASS="LITERAL">step</TT> is the real intellectual input into the    model, and is worth reading as an example of an agent's    behavior.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="swarm.overview.mag4.chapter.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="set.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="swarm.overview.mag4.build-agents.sect1.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Mag 4x:Sketch of Code</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="swarm.overview.mag4.chapter.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Building Agents</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -