/* * * HEATBUGS in MAML * (c) 1998, CEU Systems Laboratory * * This simulation is based on the following model: * * Heatbugs application. Copyright (C) 1996 Santa Fe Institute. * This library is distributed without any warranty; without even the * implied warranty of merchantability or fitness for a particular purpose. * See file LICENSE for details and terms of copying. * */ // This is the main file of the model. It encapsulates all the agents and // everything needed for the model itself (but not those needed for the user // interface). @model Model { // the Parameters of the model @var protected: int numBugs; @var protected: double evaporationRate; @var protected: double diffuseConstant; @var protected: int worldXSize, worldYSize; @var protected: int minIdealTemp, maxIdealTemp; @var protected: int minOutputHeat, maxOutputHeat; @var protected: double randomMoveProbability; //////////////////////////////////////////////////////////////////////////// // The components of the model $import "HeatSpace.maml.stub", "Heatbug.maml.stub"; //////////////////////////////////////////////////////////////////////////// // Variables to store the components of the model @var protected: Grid2d world; @var protected: HeatSpace heat; @var protected: [] Heatbug heatbugs; //////////////////////////////////////////////////////////////////////////// // The schedule of the model @schedule cyclic (1) { 0: @planDef seq { // The following subroutines will // be executed in this order in // each timestep @to heat stepRule; // The heat must dissolve @forEach groupOfHeatbug step; // The bugs must move @to heat updateLattice; // Finalization of the heat update } } //////////////////////////////////////////////////////////////////////////// // Initialization of the model @init: // Creating the heat grid @create HeatSpace heat { [heat setSizeX: worldXSize Y: worldYSize]; [heat setDiffusionConstant: diffuseConstant]; [heat setEvaporationRate: evaporationRate]; } // Creating the grid holding the agents @create Grid2d world { [world setSizeX: worldXSize Y: worldYSize]; } // Creating the agents [world setOverwriteWarnings: 0]; // Hacking inherited from Swarm @create [numBugs:i] Heatbug heatbugs { int idealTemp = [uniformIntRand getIntegerWithMin: minIdealTemp withMax: maxIdealTemp]; int outputHeat = [uniformIntRand getIntegerWithMin: minOutputHeat withMax: maxOutputHeat]; [heatbugs[i] setWorld: world Heat: heat]; [heatbugs[i] setIdealTemperature: idealTemp]; [heatbugs[i] setOutputHeat: outputHeat]; // random position [heatbugs[i] setX: [uniformIntRand getIntegerWithMin: 0L withMax: (worldXSize-1)] Y: [uniformIntRand getIntegerWithMin: 0L withMax: (worldYSize-1)]]; } [world setOverwriteWarnings: 1]; // End of hacking }