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

📄 swarm.overview.mag4.chapter.html

📁 set for Swarm2.1是圣菲研究院的开发人员对Swarm的特性及其使用描述的最为完备的指南性文档。从这里可以获得最细致的平台说明。
💻 HTML
字号:
<HTML><HEAD><TITLE>Mag 4x:Sketch of Code </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="Brief Overview of Swarm"HREF="book149.html"><LINKREL="PREVIOUS"TITLE="Summary"HREF="swarm.overview.mag3.summary.sect1.html"><LINKREL="NEXT"TITLE="Defining an Agent"HREF="swarm.overview.mag4.define-agent.sect1.html"></HEAD><BODYCLASS="CHAPTER"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.mag3.summary.sect1.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="swarm.overview.mag4.define-agent.sect1.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="SWARM.OVERVIEW.MAG4.CHAPTER">Chapter 4. Mag 4x:Sketch of Code </A></H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT>4.1. <AHREF="swarm.overview.mag4.chapter.html#SWARM.OVERVIEW.MAG4.MODEL-SWARM.SECT1">Building a Model Swarm</A></DT><DT>4.2. <AHREF="swarm.overview.mag4.define-agent.sect1.html">Defining an Agent</A></DT><DT>4.3. <AHREF="swarm.overview.mag4.build-agents.sect1.html">Building Agents</A></DT><DT>4.4. <AHREF="swarm.overview.mag4.build-space.sect1.html">Building Space objects</A></DT><DT>4.5. <AHREF="swarm.overview.mag4.schedule-swarm.sect1.html">Scheduling a Model Swarm</A></DT><DT>4.6. <AHREF="swarm.overview.mag4.build-observer.sect1.html">Building a Graphical Observer Swarm</A></DT><DT>4.7. <AHREF="swarm.overview.mag4.build-graph.sect1.html">Building a Data Graph</A></DT><DT>4.8. <AHREF="swarm.overview.mag4.main-func.sect1.html">The main() function</A></DT></DL></DIV><P>Now that we have multiple Swarms and an experimental  apparatus, it's time to learn how to use the objects themselves  inside an application. Some examples are provided here: to  understand this better, it will be necessary to read through example  applications and the library documentation. These examples come from  the Heatbugs application.</P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.OVERVIEW.MAG4.MODEL-SWARM.SECT1">4.1. Building a Model Swarm</A></H1><P>The key component of a simulation is the model Swarm. Here    is the definition of a HeatbugModelSwarm, from    HeatbugModelSwarm.h</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">      @interface HeatbugModelSwarm : Swarm { int numBugs; // simulation parameters double evaporationRate; double diffuseConstant; int worldXSize, worldYSize; int minIdealTemp, maxIdealTemp; int minOutputHeat, maxOutputHeat; double randomMoveProbability; id modelActions; // scheduling data structures id modelSchedule; id heatbugList; // list of all the heatbugs Grid2d * world; // objects representing HeatSpace * heat; // the world}-getHeatbugList; // access methods into the-(Grid2d *) getWorld; // model swarm. These methods-(HeatSpace *) getHeat; // allow the model swarm to be observed.+createBegin: aZone; // extra methods you-createEnd; // provide for Swarms-buildObjects;-buildActions;-activateIn: swarmContext;    </PRE></TD></TR></TABLE><P>The first section of code says that a HeatbugModelSwarm is a    kind of Swarm.  HeatbugModelSwarm inherits a lot of behavior from    generic Swarm, but also adds new variables and methods.</P><P>The new variables are enclosed in the braces in the definition    of HeatbugModelSwarm.  They are split into three general classes    of things: simulation parameters, schedule data structures, and    objects in the world. This is a typical sort of model swarm.</P><P>Finally, a HeatbugModelSwarm defines new methods. The first    few methods are used to allow the model to be observed: a    HeatbugModelSwarm will give out its list of Heatbugs, for    instance, or its HeatSpace. Observers use these methods to monitor    the model.</P><P>In addition to the observation methods, there are several    Swarm-specific methods for the building of Swarms. These are    fairly stereotyped. The <TTCLASS="LITERAL">createBegin</TT> and    <TTCLASS="LITERAL">createEnd</TT> messages are used to create the Swarm    object itself.  <TTCLASS="LITERAL">buildObjects</TT> builds the model    objects, and <TTCLASS="LITERAL">buildActions</TT> builds the model    schedule - more on these later. Finally,    <TTCLASS="LITERAL">activateIn</TT> arranges for the execution machinery    to execute the Swarm itself. </P></DIV></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.mag3.summary.sect1.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.define-agent.sect1.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Summary</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="book149.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Defining an Agent</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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