Packages

  • package root
    Definition Classes
    root
  • package o1
    Definition Classes
    root
  • package city
    Definition Classes
    o1
  • package gui
  • CityMap
  • Demographic
  • Occupied
  • Simulator
  • Vacant
  • package grid

    This package contains tools for working with grid-like two-dimensional structures.

    This package contains tools for working with grid-like two-dimensional structures.

    The contents of this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

    Definition Classes
    o1
  • package util
    Definition Classes
    o1
p

o1

city

package city

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Package Members

  1. package gui

Type Members

  1. 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 a CityMap is either Vacant or stores a household that belongs to aparticular demographic.

    A CityMap is mutable. As a household moves, the corresponding Demographic object moves to a different GridPos on the CityMap.

  2. 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 and Occupied:

    • 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.

  3. final class Occupied extends Demographic

    An Occupied object signals that a household belongs to a demographic specific by the color label stored within the Occupied object.

    An Occupied object signals that a household belongs to a demographic specific by the color label stored within the Occupied object. For instance, a residence may be "occupied by the red demographic", or "occupied by the blue demographic".

    An Occupied object is immutable

  4. 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 are startNew, which launches a new simulation, and moveResidents, 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: Calling startNew causes the simulator to discard any previously active simulation and start processing a new one. Calling moveResidents modifies the state of the active simulation.

Value Members

  1. 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.

Ungrouped