package city
- Alphabetic
- Public
- Protected
Type Members
- class CityMap extends o1.Grid[Demographic]
A
CityMap
is a square grid that represents a simplified map of a city.A
CityMap
is 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 aCityMap
is eitherVacant
or stores a household that belongs to aparticular demographic.A
CityMap
is mutable. As a household moves, the correspondingDemographic
object moves to a differentGridPos
on theCityMap
. - sealed trait Demographic extends AnyRef
A
Demographic
indicates which demographic ("slice of the overall population") a particular household belongs to (if any).A
Demographic
indicates 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
Demographic
objects:Vacant
andOccupied
:- 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
Demographic
objects are immutable.The trait
Demographic
itself does not define any methods; it merely serves as a supertype for Occupied and Vacant. - final class Occupied extends Demographic
An
Occupied
object signals that a household belongs to a demographic specific by the color label stored within theOccupied
object.An
Occupied
object signals that a household belongs to a demographic specific by the color label stored within theOccupied
object. For instance, a residence may be "occupied by the red demographic", or "occupied by the blue demographic".An
Occupied
object is immutable - class Simulator extends AnyRef
A
Simulator
object is a city simulator based on Schelling’s model of emergent social segregation.A
Simulator
object 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
Simulator
is mutable: CallingstartNew
causes the simulator to discard any previously active simulation and start processing a new one. CallingmoveResidents
modifies 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.