package city
- Alphabetic
- Public
- Protected
Type Members
- class CityMap extends o1.Grid[Demographic]
A
CityMapis a square grid that represents a simplified map of a city.A
CityMapis a square grid that represents a simplified map of a city. It is a Grid whose elements are Demographic objects. That is, each GridPos ("street address") on aCityMapis eitherVacantor stores a household that belongs to aparticular demographic.A
CityMapis mutable. As a household moves, the correspondingDemographicobject moves to a differentGridPoson theCityMap. - sealed trait Demographic extends AnyRef
A
Demographicindicates which demographic ("slice of the overall population") a particular household belongs to (if any).A
Demographicindicates which demographic ("slice of the overall population") a particular household belongs to (if any). It is used by the simulator to mark households on a city map.There are two kinds of
Demographicobjects:VacantandOccupied:- The singleton object Vacant is used for indicating that a residence is empty and does not belong to any demographic.
- Occupied objects indicate that a residence belongs to a
specific demographic; each different demographic is assigned
a different
Color. For instance, a residence may be "occupied by the red demographic", or "occupied by the blue demographic".
What exactly constitutes a demographic is unimportant for the purposes of this class. Demographics could be based on people's socioeconomic status, political views, ethnicity, age, or something else.
All
Demographicobjects are immutable.The trait
Demographicitself does not define any methods; it merely serves as a supertype for Occupied and Vacant. - final class Occupied extends Demographic
An
Occupiedobject signals that a household belongs to a demographic specific by the color label stored within theOccupiedobject.An
Occupiedobject signals that a household belongs to a demographic specific by the color label stored within theOccupiedobject. For instance, a residence may be "occupied by the red demographic", or "occupied by the blue demographic".An
Occupiedobject is immutable - class Simulator extends AnyRef
A
Simulatorobject is a city simulator based on Schelling’s model of emergent social segregation.A
Simulatorobject is a city simulator based on Schelling’s model of emergent social segregation. Its key methods arestartNew, which launches a new simulation, andmoveResidents, which advances the most recently launched simulation by moving dissatisfied residents into vacant homes. A selection of other methods is also provided for examining the state of the simulation.As implied above, a
Simulatoris mutable: CallingstartNewcauses the simulator to discard any previously active simulation and start processing a new one. CallingmoveResidentsmodifies the state of the active simulation.
Value Members
- object Vacant extends Demographic
This immutable singleton object effectively means "no demographic at all".
This immutable singleton object effectively means "no demographic at all". It can be used on a CityMap to indicate that a residence is empty.