Methapolis  0.27
 All Classes Namespaces Files Functions Variables Enumerator
micropolisj.engine.Micropolis Class Reference
Inheritance diagram for micropolisj.engine.Micropolis:
Collaboration diagram for micropolisj.engine.Micropolis:

Classes

class  FinancialHistory
class  History
interface  Listener

Public Member Functions

void spend (int amount, PlayerInfo playerInfo)
void spend (int amount)
 Micropolis ()
 Micropolis (int width, int height)
List< SpritegetSprites ()
void fireFundsChanged ()
void addListener (Listener l)
void removeListener (Listener l)
void addEarthquakeListener (EarthquakeListener l)
void removeEarthquakeListener (EarthquakeListener l)
void addMapListener (MapListener l)
void removeMapListener (MapListener l)
void addTempelListener (TempelListener listener)
void notifyCountdown (int countdown)
void notifyEnd ()
int getWidth ()
int getHeight ()
char getTile (int xpos, int ypos)
char getTileRaw (int xpos, int ypos)
boolean isTilePowered (int xpos, int ypos)
void setTile (int xpos, int ypos, char newTile)
void setTile (int xpos, int ypos, char newTile, int playerID)
final boolean testBounds (int xpos, int ypos)
boolean isBudgetTime ()
void calculateCenterMass ()
int getFireStationCoverage (int xpos, int ypos)
int getLandValue (int xpos, int ypos)
int getTrafficDensity (int xpos, int ypos)
CityLocation getLocationOfMaxPollution ()
void addResearchPoints ()
void addResearchPoints (int playerID)
BudgetNumbers generateBudget ()
BudgetNumbers generateBudget (PlayerInfo playerInfo)
void load (File filename) throws IOException
void load (InputStream inStream) throws IOException
void save (File filename) throws IOException
void save (OutputStream outStream) throws IOException
void toggleAutoBudget ()
void toggleAutoBulldoze ()
void toggleDisasters ()
void setSpeed (Speed newSpeed)
void animate ()
Sprite[] allSprites ()
int getCityPopulation ()
int getCityPopulation (int playerID)
void makeEarthquake ()
void makeFire ()
boolean makeMeltdown ()
void makeMonster ()
void makeTornado ()
void makeFlood ()
ZoneStatus queryZoneStatus (int xpos, int ypos)
int getResValve ()
int getComValve ()
int getIndValve ()
void setGameLevel (int newLevel)
void setFunds (int totalFunds)
int getPlayerID ()
void setBudgetNumbers (int newTaxRate, double roadPct, double newRoadPct, double newPolicePct, double newFirePct, double newResearchPct)
int getNumberOfPlayers ()
PlayerInfo getPlayerInfo ()
PlayerInfo getPlayerInfo (int playerID)

Public Attributes

int[][] pollutionMem
int[][] crimeMem
int[][] popDensity
int[][] rateOGMem
int[][] fireRate
int[][] policeMapEffect
int[][] researchMapEffect
PlayerInfo playerInfo
Stack< CityLocationpowerPlants = new Stack<CityLocation>()
boolean autoBulldoze = true
boolean autoBudget = false
Speed simSpeed = Speed.NORMAL
boolean noDisasters = true
int gameLevel
int cityTime
MainWindow mainWindow
History history = new History()
ArrayList< FinancialHistory > financialHistory = new ArrayList<FinancialHistory>()

Static Public Attributes

static final int CENSUSRATE = 4

Protected Member Functions

void init (int width, int height)
void fireCensusChanged ()
void fireCityMessage (MicropolisMessage message, CityLocation loc)
void fireDemandChanged ()
void fireEvaluationChanged ()
void fireMapOverlayDataChanged (MapState overlayDataType)
void fireTileChanged (int xpos, int ypos)
void fireWholeMapChanged ()
void mapScan (int x0, int x1)
void takeCensus ()
void takeCensus2 ()
void moveObjects ()
void animateTiles ()

Protected Attributes

char[][] map
List< Spritesprites = new ArrayList<Sprite>()

Private Member Functions

int computePopDen (int x, int y, char tile)
void popDenScan ()
void distIntMarket ()
void decROGMem ()
void decTrafficMem ()
int[][] smoothFirePoliceMap (int[][] omap)
boolean testForCond (CityLocation loc, int dir)
boolean movePowerLocation (CityLocation loc, int dir)

Static Private Member Functions

static int[][] doSmooth (int[][] tem)

Private Attributes

int powerPlayer = 0

Detailed Description

The main simulation engine for Micropolis. The front-end should call animate() periodically to move the simulation forward in time.

Definition at line 70 of file Micropolis.java.

Constructor & Destructor Documentation

micropolisj.engine.Micropolis.Micropolis ( )

Definition at line 203 of file Micropolis.java.

micropolisj.engine.Micropolis.Micropolis ( int  width,
int  height 
)

Definition at line 210 of file Micropolis.java.

References micropolisj.engine.Micropolis.init(), and micropolisj.engine.Micropolis.playerInfo.

Here is the call graph for this function:

Member Function Documentation

void micropolisj.engine.Micropolis.addEarthquakeListener ( EarthquakeListener  l)
void micropolisj.engine.Micropolis.addResearchPoints ( )

Definition at line 1640 of file Micropolis.java.

void micropolisj.engine.Micropolis.addTempelListener ( TempelListener  listener)

Definition at line 358 of file Micropolis.java.

Referenced by micropolisj.gui.MainWindow.MainWindow().

void micropolisj.engine.Micropolis.animate ( )
void micropolisj.engine.Micropolis.animateTiles ( )
protected
void micropolisj.engine.Micropolis.calculateCenterMass ( )

Definition at line 679 of file Micropolis.java.

References micropolisj.engine.Micropolis.popDenScan().

Referenced by micropolisj.gui.OverlayMapView.setEngine(), and micropolisj.gui.OverlayMapView.wholeMapChanged().

Here is the call graph for this function:

int micropolisj.engine.Micropolis.computePopDen ( int  x,
int  y,
char  tile 
)
private

Definition at line 637 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.popDenScan().

void micropolisj.engine.Micropolis.decROGMem ( )
private

Definition at line 745 of file Micropolis.java.

References micropolisj.engine.Micropolis.rateOGMem.

void micropolisj.engine.Micropolis.decTrafficMem ( )
private

Definition at line 772 of file Micropolis.java.

void micropolisj.engine.Micropolis.distIntMarket ( )
private

Definition at line 733 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.popDenScan().

static int [][] micropolisj.engine.Micropolis.doSmooth ( int  tem[][])
staticprivate

Definition at line 653 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.popDenScan().

void micropolisj.engine.Micropolis.fireCensusChanged ( )
protected

Definition at line 254 of file Micropolis.java.

Referenced by micropolisj.network.ClientMicropolis.fireEvents().

void micropolisj.engine.Micropolis.fireCityMessage ( MicropolisMessage  message,
CityLocation  loc 
)
protected

Definition at line 260 of file Micropolis.java.

void micropolisj.engine.Micropolis.fireDemandChanged ( )
protected
void micropolisj.engine.Micropolis.fireEvaluationChanged ( )
protected

Definition at line 284 of file Micropolis.java.

Referenced by micropolisj.network.ClientMicropolis.fireEvents().

void micropolisj.engine.Micropolis.fireMapOverlayDataChanged ( MapState  overlayDataType)
protected

Definition at line 296 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.popDenScan().

void micropolisj.engine.Micropolis.fireTileChanged ( int  xpos,
int  ypos 
)
protected
void micropolisj.engine.Micropolis.fireWholeMapChanged ( )
protected
BudgetNumbers micropolisj.engine.Micropolis.generateBudget ( )
BudgetNumbers micropolisj.engine.Micropolis.generateBudget ( PlayerInfo  playerInfo)

Calculate the current playerInfo.budget numbers.

Definition at line 1735 of file Micropolis.java.

References micropolisj.engine.PlayerInfo.budget, micropolisj.engine.PlayerInfo.cityTax, micropolisj.engine.BudgetNumbers.fireFunded, micropolisj.engine.BudgetNumbers.firePercent, micropolisj.engine.PlayerInfo.firePercent, micropolisj.engine.BudgetNumbers.fireRequest, micropolisj.engine.Micropolis.gameLevel, micropolisj.engine.PlayerInfo.landValueAverage, micropolisj.engine.PlayerInfo.lastFireStationCount, micropolisj.engine.PlayerInfo.lastPoliceCount, micropolisj.engine.PlayerInfo.lastRailTotal, micropolisj.engine.PlayerInfo.lastResearchCount, micropolisj.engine.PlayerInfo.lastRoadTotal, micropolisj.engine.PlayerInfo.lastTotalPop, micropolisj.engine.BudgetNumbers.newBalance, micropolisj.engine.BudgetNumbers.operatingExpenses, micropolisj.engine.BudgetNumbers.policeFunded, micropolisj.engine.BudgetNumbers.policePercent, micropolisj.engine.PlayerInfo.policePercent, micropolisj.engine.BudgetNumbers.policeRequest, micropolisj.engine.BudgetNumbers.previousBalance, micropolisj.engine.BudgetNumbers.researchFunded, micropolisj.engine.BudgetNumbers.researchPercent, micropolisj.engine.PlayerInfo.researchPercent, micropolisj.engine.BudgetNumbers.researchRequest, micropolisj.engine.BudgetNumbers.roadFunded, micropolisj.engine.BudgetNumbers.roadPercent, micropolisj.engine.PlayerInfo.roadPercent, micropolisj.engine.BudgetNumbers.roadRequest, micropolisj.engine.BudgetNumbers.taxIncome, micropolisj.engine.BudgetNumbers.taxRate, and micropolisj.engine.CityBudget.totalFunds.

int micropolisj.engine.Micropolis.getCityPopulation ( )

Definition at line 2175 of file Micropolis.java.

References micropolisj.engine.Micropolis.getPlayerID().

Referenced by micropolisj.engine.Micropolis.addResearchPoints().

Here is the call graph for this function:

int micropolisj.engine.Micropolis.getCityPopulation ( int  playerID)

Definition at line 2179 of file Micropolis.java.

References micropolisj.engine.Micropolis.getPlayerInfo(), and micropolisj.engine.PlayerInfo.lastCityPop.

Here is the call graph for this function:

int micropolisj.engine.Micropolis.getComValve ( )

Definition at line 2643 of file Micropolis.java.

References micropolisj.engine.PlayerInfo.comValve, and micropolisj.engine.Micropolis.getPlayerInfo().

Referenced by micropolisj.gui.DemandIndicator.paintComponent().

Here is the call graph for this function:

int micropolisj.engine.Micropolis.getFireStationCoverage ( int  xpos,
int  ypos 
)

Accessor method for fireRate[].

Definition at line 1050 of file Micropolis.java.

References micropolisj.engine.Micropolis.fireRate.

int micropolisj.engine.Micropolis.getIndValve ( )

Definition at line 2647 of file Micropolis.java.

References micropolisj.engine.Micropolis.getPlayerInfo(), and micropolisj.engine.PlayerInfo.indValve.

Referenced by micropolisj.gui.DemandIndicator.paintComponent().

Here is the call graph for this function:

int micropolisj.engine.Micropolis.getLandValue ( int  xpos,
int  ypos 
)

Accessor method for landValueMem overlay.

Definition at line 1055 of file Micropolis.java.

References micropolisj.engine.Micropolis.testBounds().

Referenced by micropolisj.gui.OverlayMapView.checkLandValueOverlay().

Here is the call graph for this function:

int micropolisj.engine.Micropolis.getNumberOfPlayers ( )

Reimplemented in micropolisj.network.ServerMicropolis.

Definition at line 2674 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.animate().

PlayerInfo micropolisj.engine.Micropolis.getPlayerInfo ( int  playerID)

Reimplemented in micropolisj.network.ClientMicropolis, and micropolisj.network.ServerMicropolis.

Definition at line 2682 of file Micropolis.java.

References micropolisj.engine.Micropolis.getPlayerID(), and micropolisj.engine.Micropolis.playerInfo.

Here is the call graph for this function:

int micropolisj.engine.Micropolis.getResValve ( )

Definition at line 2639 of file Micropolis.java.

References micropolisj.engine.Micropolis.getPlayerInfo(), and micropolisj.engine.PlayerInfo.resValve.

Referenced by micropolisj.gui.DemandIndicator.paintComponent().

Here is the call graph for this function:

List<Sprite> micropolisj.engine.Micropolis.getSprites ( )

Definition at line 250 of file Micropolis.java.

References micropolisj.engine.Micropolis.sprites.

char micropolisj.engine.Micropolis.getTileRaw ( int  xpos,
int  ypos 
)
int micropolisj.engine.Micropolis.getTrafficDensity ( int  xpos,
int  ypos 
)

Definition at line 1064 of file Micropolis.java.

References micropolisj.engine.Micropolis.testBounds().

Referenced by micropolisj.gui.OverlayMapView.checkTrafficOverlay(), and micropolisj.engine.HelicopterSprite.moveImpl().

Here is the call graph for this function:

boolean micropolisj.engine.Micropolis.isBudgetTime ( )

Checks whether the next call to animate() will collect taxes and process the playerInfo.budget.

Definition at line 482 of file Micropolis.java.

References micropolisj.engine.Micropolis.cityTime.

Referenced by micropolisj.gui.MainWindow.startTimer().

boolean micropolisj.engine.Micropolis.isTilePowered ( int  xpos,
int  ypos 
)

Definition at line 452 of file Micropolis.java.

References micropolisj.engine.Micropolis.getTileRaw().

Referenced by micropolisj.gui.MicropolisDrawingArea.paintComponent().

Here is the call graph for this function:

void micropolisj.engine.Micropolis.load ( File  filename) throws IOException
void micropolisj.engine.Micropolis.load ( InputStream  inStream) throws IOException
boolean micropolisj.engine.Micropolis.makeMeltdown ( )

Force a meltdown to occur.

Returns
true if a metldown was initiated.

Definition at line 2243 of file Micropolis.java.

References micropolisj.engine.Micropolis.getTile(), micropolisj.engine.Micropolis.map, micropolisj.engine.CityLocation.x, and micropolisj.engine.CityLocation.y.

Here is the call graph for this function:

void micropolisj.engine.Micropolis.makeMonster ( )
void micropolisj.engine.Micropolis.makeTornado ( )
void micropolisj.engine.Micropolis.mapScan ( int  x0,
int  x1 
)
protected

Definition at line 1395 of file Micropolis.java.

References micropolisj.engine.Micropolis.getHeight().

Here is the call graph for this function:

void micropolisj.engine.Micropolis.moveObjects ( )
protected

Definition at line 2153 of file Micropolis.java.

References micropolisj.engine.Micropolis.allSprites().

Referenced by micropolisj.network.ClientMicropolis.animate(), and micropolisj.engine.Micropolis.animate().

Here is the call graph for this function:

boolean micropolisj.engine.Micropolis.movePowerLocation ( CityLocation  loc,
int  dir 
)
private
void micropolisj.engine.Micropolis.notifyCountdown ( int  countdown)

Definition at line 362 of file Micropolis.java.

References micropolisj.engine.TempelListener.onCountdown().

Here is the call graph for this function:

void micropolisj.engine.Micropolis.notifyEnd ( )

Definition at line 367 of file Micropolis.java.

References micropolisj.engine.TempelListener.onEnd().

Here is the call graph for this function:

void micropolisj.engine.Micropolis.removeEarthquakeListener ( EarthquakeListener  l)

Definition at line 342 of file Micropolis.java.

Referenced by micropolisj.gui.MainWindow.setEngine().

void micropolisj.engine.Micropolis.removeMapListener ( MapListener  l)
void micropolisj.engine.Micropolis.save ( File  filename) throws IOException
void micropolisj.engine.Micropolis.save ( OutputStream  outStream) throws IOException

Definition at line 2103 of file Micropolis.java.

References micropolisj.engine.Micropolis.history.

void micropolisj.engine.Micropolis.setBudgetNumbers ( int  newTaxRate,
double  roadPct,
double  newRoadPct,
double  newPolicePct,
double  newFirePct,
double  newResearchPct 
)
void micropolisj.engine.Micropolis.setFunds ( int  totalFunds)
void micropolisj.engine.Micropolis.setGameLevel ( int  newLevel)
void micropolisj.engine.Micropolis.setSpeed ( Speed  newSpeed)
void micropolisj.engine.Micropolis.setTile ( int  xpos,
int  ypos,
char  newTile 
)
void micropolisj.engine.Micropolis.setTile ( int  xpos,
int  ypos,
char  newTile,
int  playerID 
)

Definition at line 466 of file Micropolis.java.

References micropolisj.util.Utilities.codePlayerID(), and micropolisj.engine.Micropolis.setTile().

Here is the call graph for this function:

int [][] micropolisj.engine.Micropolis.smoothFirePoliceMap ( int  omap[][])
private

Definition at line 875 of file Micropolis.java.

void micropolisj.engine.Micropolis.spend ( int  amount,
PlayerInfo  playerInfo 
)
void micropolisj.engine.Micropolis.spend ( int  amount)

Definition at line 199 of file Micropolis.java.

References micropolisj.engine.Micropolis.playerInfo, and micropolisj.engine.Micropolis.spend().

Here is the call graph for this function:

boolean micropolisj.engine.Micropolis.testForCond ( CityLocation  loc,
int  dir 
)
private
void micropolisj.engine.Micropolis.toggleAutoBudget ( )
void micropolisj.engine.Micropolis.toggleAutoBulldoze ( )
void micropolisj.engine.Micropolis.toggleDisasters ( )

Member Data Documentation

boolean micropolisj.engine.Micropolis.autoBulldoze = true

Definition at line 165 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.toggleAutoBulldoze().

final int micropolisj.engine.Micropolis.CENSUSRATE = 4
static

Definition at line 191 of file Micropolis.java.

int [][] micropolisj.engine.Micropolis.crimeMem

For each 2x2 section of the city, the crime level of the city (0-250). 0 is no crime; 250 is maximum crime. Updated each cycle by crimeScan(); affects land value.

Definition at line 103 of file Micropolis.java.

Referenced by micropolisj.gui.OverlayMapView.drawCrimeMap(), micropolisj.engine.Micropolis.init(), and micropolisj.engine.Micropolis.queryZoneStatus().

ArrayList<FinancialHistory> micropolisj.engine.Micropolis.financialHistory = new ArrayList<FinancialHistory>()

Definition at line 1693 of file Micropolis.java.

Referenced by micropolisj.gui.BudgetDialog.makeBalancePane().

History micropolisj.engine.Micropolis.history = new History()
MainWindow micropolisj.engine.Micropolis.mainWindow
boolean micropolisj.engine.Micropolis.noDisasters = true
int [][] micropolisj.engine.Micropolis.policeMapEffect
int [][] micropolisj.engine.Micropolis.pollutionMem

For each 2x2 section of the city, the pollution level of the city (0-255). 0 is no pollution; 255 is maximum pollution. Updated each cycle by ptlScan(); affects land value.

Definition at line 96 of file Micropolis.java.

Referenced by micropolisj.gui.OverlayMapView.drawPollutionMap(), micropolisj.engine.Micropolis.init(), and micropolisj.engine.Micropolis.queryZoneStatus().

int [][] micropolisj.engine.Micropolis.popDensity

For each 2x2 section of the city, the population density (0-?). Used for map overlays and as a factor for crime rates.

Definition at line 109 of file Micropolis.java.

Referenced by micropolisj.gui.OverlayMapView.drawPopDensity(), micropolisj.engine.Micropolis.init(), and micropolisj.engine.Micropolis.popDenScan().

Stack<CityLocation> micropolisj.engine.Micropolis.powerPlants = new Stack<CityLocation>()

Definition at line 162 of file Micropolis.java.

int micropolisj.engine.Micropolis.powerPlayer = 0
private

Definition at line 965 of file Micropolis.java.

int [][] micropolisj.engine.Micropolis.rateOGMem

For each 8x8 section of the city, the rate of growth. Capped to a number between -200 and 200. Used for reporting purposes only; the number has no affect.

Definition at line 134 of file Micropolis.java.

Referenced by micropolisj.engine.Micropolis.decROGMem(), micropolisj.gui.OverlayMapView.drawRateOfGrowth(), micropolisj.engine.Micropolis.init(), and micropolisj.engine.Micropolis.queryZoneStatus().

int [][] micropolisj.engine.Micropolis.researchMapEffect

Definition at line 142 of file Micropolis.java.


The documentation for this class was generated from the following file: