Package game.core
Class G
java.lang.Object
game.core.G
- All Implemented Interfaces:
Game
- Direct Known Subclasses:
_G_
public class G extends java.lang.Object implements Game
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected PacManSimulator.GameConfigconfigprotected int[]curGhostLocsprotected intcurMazeprotected intcurPacManLocprotected int[]edibleTimesprotected booleanextraLifeprotected booleangameOverprotected intghostEatMultiplierprotected int[]lairTimesprotected int[]lastGhostDirsprotected intlastPacManDirprotected intlevelTimeprotected intlivesRemainingprotected static G.Maze[]mazesprotected java.util.BitSetpillsprotected java.util.BitSetpowerPillsprotected intremainingLevelsstatic java.util.Randomrndprotected intscoreprotected inttotalTimeprotected inttotLevelFields inherited from interface game.core.Game
COMMON_LAIR_TIME, DOWN, EAT_DISTANCE, EDIBLE_TIME, EDIBLE_TIME_REDUCTION, EMPTY, EXTRA_LIFE_SCORE, GHOST_EAT_SCORE, GHOST_REVERSAL, GHOST_SPEED_REDUCTION, INITIAL_GHOST_DIRS, INITIAL_PAC_DIR, LAIR_REDUCTION, LAIR_TIMES, LEFT, LEVEL_LIMIT, MAX_LEVELS, NUM_GHOSTS, NUM_LIVES, NUM_MAZES, PILL, POWER_PILL, RIGHT, UP -
Constructor Summary
Constructors Modifier Constructor Description protectedG() -
Method Summary
Modifier and Type Method Description int[]advanceGame(PacManAction pacMan, GhostsActions ghosts)int[]advanceGameReplay(PacManAction pacMan, GhostsActions ghosts, int pacManLocation, int[] ghostsLocations)protected intcheckGhostDir(int whichGhost, int direction)protected voidcheckLevelState()protected intcheckPacManDir(int direction)booleancheckPill(int nodeIndex)booleancheckPowerPill(int nodeIndex)Gamecopy()protected voiddecimatePills(int number)protected voideatPill()protected booleaneatPowerPill()protected voidfeast()booleangameOver()intgetCurGhostDir(int whichGhost)intgetCurGhostLoc(int whichGhost)intgetCurLevel()intgetCurMaze()intgetCurPacManDir()intgetCurPacManLoc()intgetEdibleTime(int whichGhost)doublegetEuclideanDistance(int from, int to)int[]getGhostNeighbours(int whichGhost)int[]getGhostPath(int whichGhost, int to)intgetGhostPathDistance(int whichGhost, int to)intgetGhostTarget(int whichGhost, int[] targets, boolean nearest)intgetInitialGhostsPosition()intgetInitialPacPosition()int[]getJunctionIndices()intgetLairTime(int whichGhost)intgetLevelTime()intgetLivesRemaining()intgetManhattanDistance(int from, int to)java.lang.StringgetName()intgetNeighbour(int nodeIndex, int direction)intgetNextEdibleGhostScore()intgetNextGhostDir(int whichGhost, int to, boolean closer, Game.DM measure)intgetNextPacManDir(int to, boolean closer, Game.DM measure)intgetNumActivePills()intgetNumActivePowerPills()intgetNumberOfNodes()intgetNumberPills()intgetNumberPowerPills()intgetNumNeighbours(int nodeIndex)int[]getPacManNeighbours()int[]getPath(int from, int to)intgetPathDistance(int from, int to)intgetPillIndex(int nodeIndex)int[]getPillIndices()int[]getPillIndicesActive()int[]getPossibleDirs(int curLoc, int curDir, boolean includeReverse)int[]getPossibleGhostDirs(int whichGhost)int[]getPossiblePacManDirs(boolean includeReverse)intgetPowerPillIndex(int nodeIndex)int[]getPowerPillIndices()int[]getPowerPillIndicesActive()intgetReverse(int direction)intgetScore()intgetTarget(int from, int[] targets, boolean nearest, Game.DM measure)intgetTotalTime()intgetX(int index)intgetY(int index)booleanghostRequiresAction(int whichGhost)protected voidinit()booleanisEdible(int whichGhost)booleanisJunction(int nodeIndex)protected voidreset(boolean newLevel)protected voidupdateGhosts(GhostsActions ghosts, boolean reverse)protected voidupdatePacMan(PacManAction pacMan)
-
Field Details
-
rnd
public static java.util.Random rnd -
config
-
remainingLevels
protected int remainingLevels -
mazes
-
pills
protected java.util.BitSet pills -
powerPills
protected java.util.BitSet powerPills -
curMaze
protected int curMaze -
totLevel
protected int totLevel -
levelTime
protected int levelTime -
totalTime
protected int totalTime -
score
protected int score -
ghostEatMultiplier
protected int ghostEatMultiplier -
gameOver
protected boolean gameOver -
curPacManLoc
protected int curPacManLoc -
lastPacManDir
protected int lastPacManDir -
livesRemaining
protected int livesRemaining -
extraLife
protected boolean extraLife -
curGhostLocs
protected int[] curGhostLocs -
lastGhostDirs
protected int[] lastGhostDirs -
edibleTimes
protected int[] edibleTimes -
lairTimes
protected int[] lairTimes
-
-
Constructor Details
-
G
protected G()
-
-
Method Details
-
init
protected void init() -
copy
-
reset
protected void reset(boolean newLevel) -
decimatePills
protected void decimatePills(int number) -
advanceGame
- Specified by:
advanceGamein interfaceGame
-
advanceGameReplay
public int[] advanceGameReplay(PacManAction pacMan, GhostsActions ghosts, int pacManLocation, int[] ghostsLocations) -
updatePacMan
-
checkPacManDir
protected int checkPacManDir(int direction) -
updateGhosts
-
checkGhostDir
protected int checkGhostDir(int whichGhost, int direction) -
eatPill
protected void eatPill() -
eatPowerPill
protected boolean eatPowerPill() -
feast
protected void feast() -
checkLevelState
protected void checkLevelState() -
getReverse
public int getReverse(int direction)- Specified by:
getReversein interfaceGame
-
gameOver
public boolean gameOver() -
checkPill
public boolean checkPill(int nodeIndex) -
checkPowerPill
public boolean checkPowerPill(int nodeIndex)- Specified by:
checkPowerPillin interfaceGame
-
getPacManNeighbours
public int[] getPacManNeighbours()- Specified by:
getPacManNeighboursin interfaceGame
-
getGhostNeighbours
public int[] getGhostNeighbours(int whichGhost)- Specified by:
getGhostNeighboursin interfaceGame
-
getCurLevel
public int getCurLevel()- Specified by:
getCurLevelin interfaceGame
-
getCurMaze
public int getCurMaze()- Specified by:
getCurMazein interfaceGame
-
getCurPacManLoc
public int getCurPacManLoc()- Specified by:
getCurPacManLocin interfaceGame
-
getCurPacManDir
public int getCurPacManDir()- Specified by:
getCurPacManDirin interfaceGame
-
getLivesRemaining
public int getLivesRemaining()- Specified by:
getLivesRemainingin interfaceGame
-
getCurGhostLoc
public int getCurGhostLoc(int whichGhost)- Specified by:
getCurGhostLocin interfaceGame
-
getCurGhostDir
public int getCurGhostDir(int whichGhost)- Specified by:
getCurGhostDirin interfaceGame
-
getEdibleTime
public int getEdibleTime(int whichGhost)- Specified by:
getEdibleTimein interfaceGame
-
isEdible
public boolean isEdible(int whichGhost) -
getScore
public int getScore() -
getLevelTime
public int getLevelTime()- Specified by:
getLevelTimein interfaceGame
-
getTotalTime
public int getTotalTime()- Specified by:
getTotalTimein interfaceGame
-
getNumberPills
public int getNumberPills()- Specified by:
getNumberPillsin interfaceGame
-
getNumberPowerPills
public int getNumberPowerPills()- Specified by:
getNumberPowerPillsin interfaceGame
-
getLairTime
public int getLairTime(int whichGhost)- Specified by:
getLairTimein interfaceGame
-
ghostRequiresAction
public boolean ghostRequiresAction(int whichGhost)- Specified by:
ghostRequiresActionin interfaceGame
-
getName
public java.lang.String getName() -
getInitialPacPosition
public int getInitialPacPosition()- Specified by:
getInitialPacPositionin interfaceGame
-
getInitialGhostsPosition
public int getInitialGhostsPosition()- Specified by:
getInitialGhostsPositionin interfaceGame
-
getNumberOfNodes
public int getNumberOfNodes()- Specified by:
getNumberOfNodesin interfaceGame
-
getX
public int getX(int index) -
getY
public int getY(int index) -
getPillIndex
public int getPillIndex(int nodeIndex)- Specified by:
getPillIndexin interfaceGame
-
getPowerPillIndex
public int getPowerPillIndex(int nodeIndex)- Specified by:
getPowerPillIndexin interfaceGame
-
getNeighbour
public int getNeighbour(int nodeIndex, int direction)- Specified by:
getNeighbourin interfaceGame
-
getPillIndices
public int[] getPillIndices()- Specified by:
getPillIndicesin interfaceGame
-
getPowerPillIndices
public int[] getPowerPillIndices()- Specified by:
getPowerPillIndicesin interfaceGame
-
getJunctionIndices
public int[] getJunctionIndices()- Specified by:
getJunctionIndicesin interfaceGame
-
isJunction
public boolean isJunction(int nodeIndex)- Specified by:
isJunctionin interfaceGame
-
getNextEdibleGhostScore
public int getNextEdibleGhostScore()- Specified by:
getNextEdibleGhostScorein interfaceGame
-
getNumActivePills
public int getNumActivePills()- Specified by:
getNumActivePillsin interfaceGame
-
getNumActivePowerPills
public int getNumActivePowerPills()- Specified by:
getNumActivePowerPillsin interfaceGame
-
getPillIndicesActive
public int[] getPillIndicesActive()- Specified by:
getPillIndicesActivein interfaceGame
-
getPowerPillIndicesActive
public int[] getPowerPillIndicesActive()- Specified by:
getPowerPillIndicesActivein interfaceGame
-
getNumNeighbours
public int getNumNeighbours(int nodeIndex)- Specified by:
getNumNeighboursin interfaceGame
-
getPossiblePacManDirs
public int[] getPossiblePacManDirs(boolean includeReverse)- Specified by:
getPossiblePacManDirsin interfaceGame
-
getPossibleGhostDirs
public int[] getPossibleGhostDirs(int whichGhost)- Specified by:
getPossibleGhostDirsin interfaceGame
-
getPossibleDirs
public int[] getPossibleDirs(int curLoc, int curDir, boolean includeReverse)- Specified by:
getPossibleDirsin interfaceGame
-
getNextPacManDir
- Specified by:
getNextPacManDirin interfaceGame
-
getNextGhostDir
- Specified by:
getNextGhostDirin interfaceGame
-
getPathDistance
public int getPathDistance(int from, int to)- Specified by:
getPathDistancein interfaceGame
-
getEuclideanDistance
public double getEuclideanDistance(int from, int to)- Specified by:
getEuclideanDistancein interfaceGame
-
getManhattanDistance
public int getManhattanDistance(int from, int to)- Specified by:
getManhattanDistancein interfaceGame
-
getPath
public int[] getPath(int from, int to) -
getGhostPath
public int[] getGhostPath(int whichGhost, int to)- Specified by:
getGhostPathin interfaceGame
-
getTarget
-
getGhostTarget
public int getGhostTarget(int whichGhost, int[] targets, boolean nearest)- Specified by:
getGhostTargetin interfaceGame
-
getGhostPathDistance
public int getGhostPathDistance(int whichGhost, int to)- Specified by:
getGhostPathDistancein interfaceGame
-