$import "model.maml"; @observe Segregation { @uses; // For the 2d graphics display @extendAgent Resident { @sub: (void) drawSelfOn: (id) r { [r drawPointX: posX Y: posY Color: color]; } } @probe: var "citySize", var "numOfResidents", var "ratio", var "minLimit", var "maxLimit", var "minAgeLimit", var "maxAgeLimit", var "emptyIsOK"; @var: id colormap; @var: id cityRaster; @var: id cityDisplay; @var: int displayFrequency; @probe: var "displayFrequency"; @schedule cyclic (displayFrequency) { 0: @planDef { @to cityRaster erase; @to cityDisplay display; @to cityRaster drawSelf; } } @init: citySize = 50; numOfResidents = 2000; ratio = 50; minAgeLimit = 0; maxAgeLimit = 80; minLimit = 0.25; maxLimit = 0.70; emptyIsOK = true; displayFrequency = 1; @buildProbes; [model probe]; [controlPanel setStateStopped]; @initModel; @create Colormap colormap; [colormap setColor: 1 ToName: "red"]; [colormap setColor: 2 ToName: "blue"]; @create ZoomRaster cityRaster; [cityRaster setColormap: colormap]; [cityRaster setZoomFactor: 6]; [cityRaster setWidth: citySize Height: citySize]; [cityRaster setWindowTitle: "Schelling's Segregation City"]; [cityRaster pack]; @create Object2dDisplay cityDisplay { [cityDisplay setDisplayWidget: cityRaster]; [cityDisplay setDiscrete2dToDisplay: city]; [cityDisplay setObjectCollection: groupOfResident]; [cityDisplay setDisplayMessage: M(drawSelfOn:)]; } }
Return to Contents of this issue
© Copyright Journal of Artificial Societies and Social Simulation, 1999