SchellingSwarm - Header files


schelling_2.0/DiscreteToroid.h


See objectfile

// Swarm library. 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.

/* 
  DiscreteToroid.h

  Subclass of Discrete2d with some built in support for toroidal
  geometry. The -wrapXCoord and-wrapYCoord methods provide
  for explicitly wrapping arbitrary coordinate values to
  suit the space; this class also overrides the -getObjectAtX:Y:
  and -putObject:AtX:Y: methods so that the provided coordinates
  are first wrapped (to be sure to be sure (;-).

  Barry McMullin 
  26-SEP-1996
*/

#import <space.h>

@interface DiscreteToroid: Discrete2d 

-(int) wrapXCoord: (int) inX;
-(int) wrapYCoord: (int) inY;

@end



schelling_2.0/ModelSwarm.h


See objectfile

// Schellings Segregation Model 
// Code by Benedikt Stefansson, . 
// First version July 1997
// Second version February 1998

#import "Person.h"
#import "SchellingWorld.h"
#import "Neighborhood.h"
#import "Shuffler.h"
#import <swarmobject.h>
#import <space.h>
#import <activity.h>
#import <collections.h>
#import <random.h>
#import <string.h>

@interface ModelSwarm : Swarm {
  int numAgents;
  char * neighborhood_type;
  int worldSize;
  double fractionVacant;
  double fractionBlue;
  double blueToleranceUpper;
  double blueToleranceLower;
  double redToleranceUpper;
  double redToleranceLower;
  unsigned randomSeed;
  
  id modelSchedule;

  id  aGenerator;
  id  uniformDouble;
  id  uniformInteger;
  
  id  agentList;
  id world;
  
}

+createBegin: (id) aZone;		
-createEnd;				
-buildObjects;
-buildActions;
-activateIn: (id) swarmContext;
-getAgentList;
-getWorld;
-(int)getWorldSize;
-(double)getRandomDoubleMin: (double) min Max: (double) max;
-(double)getRandomDouble;
-(int)getRandomIntMin: (int) min Max: (int) max;
@end



schelling_2.0/Neighborhood.h


See objectfile

#import <swarmobject.h>
#import "SchellingWorld.h"

@interface Neighborhood: SwarmObject {
  int myType;
  int myX;
  int myY;
  SchellingWorld * myWorld;
}

-setX: (int) x Y: (int) y;
-setWorld: w;
-setType: (int) t;

-(int) getX;
-(int) getY;
	
-(float)getFractionOf: (int) t;

@end



schelling_2.0/ObserverSwarm.h


See objectfile

// Schellings Segregation Model a la Axtell and Epstein
// Code by Benedikt Stefansson, . 
// First version July 1997

#import <swarmobject.h>
#import <space.h>
#import <activity.h>
#import <analysis.h>
#import <tkobjc.h>
#import <collections.h>
#import <simtools.h>
#import "ModelSwarm.h"

@interface ObserverSwarm : GUISwarm {
  int displayFrequency;				

  id displayActions;				
  id displaySchedule;

  ModelSwarm * modelSwarm;	 
  XColormap * colormap;
  ZoomRaster * worldRaster;
  Object2dDisplay * worldDisplay;
  EZGraph * moveGraph;

}

// Methods overriden to make the Swarm.
+createBegin: (id) aZone;
-createEnd;
-buildObjects;
-buildActions;
-activateIn: (id) swarmContext;
-eraseRaster;

@end



schelling_2.0/Person.h


See objectfile

// Schellings Segregation Model
// Code by Benedikt Stefansson, . 
// First version July 1997
// Second version February 1998

#import "Person.h"
#import <swarmobject.h>
#import <space.h>
#import <activity.h>
#import <collections.h>
#import <random.h>
#import "SchellingWorld.h"
#import "Neighborhood.h"

@interface Person: SwarmObject {
  int myColor;
  int unhappy;
  float myTolerance;
  SchellingWorld * myWorld;
  Neighborhood * myNeighborhood;
}
	

-setWorld: w;

-setNeighborhood: n;

-setAgentColor: (int) c;

-setTolerance: (float) t;

-step;

-moveToNewLocation;

-drawSelfOn: (id) rast;
				
-(int)getUnhappy;
-(double)getTolerance;		
-(int)getColor;
-getNeighborhood;

@end



schelling_2.0/SchellingWorld.h


See objectfile

// Schelling's Segregation Model
// Code by Benedikt Stefansson, . 
// First version July 1997
// Second version February 1998

#import "DiscreteToroid.h"

@interface SchellingWorld: DiscreteToroid {
  id modelSwarm;
}

-setModelSwarm: m;

-move: o toX: (int) x Y: (int) y;

-findEmptyLocation: o;
  
@end



schelling_2.0/Shuffler.h


See objectfile

// Swarm library.
// Copyright (C) 1996  by the Regents of the University of Michigan.
// 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.

// object to shuffle Swarm List list with num elts, in place
// from Knuth vol 2

#import <swarmobject.h>
#import <simtools.h>

@interface Shuffler: SwarmObject {
  id <UniformInteger> uniformRandom;
}

-setUniformRandom: (id) rnd;
-createEnd;
-shuffleList: list;

@end