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.GameConfig
config
protected int[]
curGhostLocs
protected int
curMaze
protected int
curPacManLoc
protected int[]
edibleTimes
protected boolean
extraLife
protected boolean
gameOver
protected int
ghostEatMultiplier
protected int[]
lairTimes
protected int[]
lastGhostDirs
protected int
lastPacManDir
protected int
levelTime
protected int
livesRemaining
protected static G.Maze[]
mazes
protected java.util.BitSet
pills
protected java.util.BitSet
powerPills
protected int
remainingLevels
static java.util.Random
rnd
protected int
score
protected int
totalTime
protected int
totLevel
Fields 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 protected
G()
-
Method Summary
Modifier and Type Method Description int[]
advanceGame(PacManAction pacMan, GhostsActions ghosts)
int[]
advanceGameReplay(PacManAction pacMan, GhostsActions ghosts, int pacManLocation, int[] ghostsLocations)
protected int
checkGhostDir(int whichGhost, int direction)
protected void
checkLevelState()
protected int
checkPacManDir(int direction)
boolean
checkPill(int nodeIndex)
boolean
checkPowerPill(int nodeIndex)
Game
copy()
protected void
decimatePills(int number)
protected void
eatPill()
protected boolean
eatPowerPill()
protected void
feast()
boolean
gameOver()
int
getCurGhostDir(int whichGhost)
int
getCurGhostLoc(int whichGhost)
int
getCurLevel()
int
getCurMaze()
int
getCurPacManDir()
int
getCurPacManLoc()
int
getEdibleTime(int whichGhost)
double
getEuclideanDistance(int from, int to)
int[]
getGhostNeighbours(int whichGhost)
int[]
getGhostPath(int whichGhost, int to)
int
getGhostPathDistance(int whichGhost, int to)
int
getGhostTarget(int whichGhost, int[] targets, boolean nearest)
int
getInitialGhostsPosition()
int
getInitialPacPosition()
int[]
getJunctionIndices()
int
getLairTime(int whichGhost)
int
getLevelTime()
int
getLivesRemaining()
int
getManhattanDistance(int from, int to)
java.lang.String
getName()
int
getNeighbour(int nodeIndex, int direction)
int
getNextEdibleGhostScore()
int
getNextGhostDir(int whichGhost, int to, boolean closer, Game.DM measure)
int
getNextPacManDir(int to, boolean closer, Game.DM measure)
int
getNumActivePills()
int
getNumActivePowerPills()
int
getNumberOfNodes()
int
getNumberPills()
int
getNumberPowerPills()
int
getNumNeighbours(int nodeIndex)
int[]
getPacManNeighbours()
int[]
getPath(int from, int to)
int
getPathDistance(int from, int to)
int
getPillIndex(int nodeIndex)
int[]
getPillIndices()
int[]
getPillIndicesActive()
int[]
getPossibleDirs(int curLoc, int curDir, boolean includeReverse)
int[]
getPossibleGhostDirs(int whichGhost)
int[]
getPossiblePacManDirs(boolean includeReverse)
int
getPowerPillIndex(int nodeIndex)
int[]
getPowerPillIndices()
int[]
getPowerPillIndicesActive()
int
getReverse(int direction)
int
getScore()
int
getTarget(int from, int[] targets, boolean nearest, Game.DM measure)
int
getTotalTime()
int
getX(int index)
int
getY(int index)
boolean
ghostRequiresAction(int whichGhost)
protected void
init()
boolean
isEdible(int whichGhost)
boolean
isJunction(int nodeIndex)
protected void
reset(boolean newLevel)
protected void
updateGhosts(GhostsActions ghosts, boolean reverse)
protected void
updatePacMan(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:
advanceGame
in 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:
getReverse
in interfaceGame
-
gameOver
public boolean gameOver() -
checkPill
public boolean checkPill(int nodeIndex) -
checkPowerPill
public boolean checkPowerPill(int nodeIndex)- Specified by:
checkPowerPill
in interfaceGame
-
getPacManNeighbours
public int[] getPacManNeighbours()- Specified by:
getPacManNeighbours
in interfaceGame
-
getGhostNeighbours
public int[] getGhostNeighbours(int whichGhost)- Specified by:
getGhostNeighbours
in interfaceGame
-
getCurLevel
public int getCurLevel()- Specified by:
getCurLevel
in interfaceGame
-
getCurMaze
public int getCurMaze()- Specified by:
getCurMaze
in interfaceGame
-
getCurPacManLoc
public int getCurPacManLoc()- Specified by:
getCurPacManLoc
in interfaceGame
-
getCurPacManDir
public int getCurPacManDir()- Specified by:
getCurPacManDir
in interfaceGame
-
getLivesRemaining
public int getLivesRemaining()- Specified by:
getLivesRemaining
in interfaceGame
-
getCurGhostLoc
public int getCurGhostLoc(int whichGhost)- Specified by:
getCurGhostLoc
in interfaceGame
-
getCurGhostDir
public int getCurGhostDir(int whichGhost)- Specified by:
getCurGhostDir
in interfaceGame
-
getEdibleTime
public int getEdibleTime(int whichGhost)- Specified by:
getEdibleTime
in interfaceGame
-
isEdible
public boolean isEdible(int whichGhost) -
getScore
public int getScore() -
getLevelTime
public int getLevelTime()- Specified by:
getLevelTime
in interfaceGame
-
getTotalTime
public int getTotalTime()- Specified by:
getTotalTime
in interfaceGame
-
getNumberPills
public int getNumberPills()- Specified by:
getNumberPills
in interfaceGame
-
getNumberPowerPills
public int getNumberPowerPills()- Specified by:
getNumberPowerPills
in interfaceGame
-
getLairTime
public int getLairTime(int whichGhost)- Specified by:
getLairTime
in interfaceGame
-
ghostRequiresAction
public boolean ghostRequiresAction(int whichGhost)- Specified by:
ghostRequiresAction
in interfaceGame
-
getName
public java.lang.String getName() -
getInitialPacPosition
public int getInitialPacPosition()- Specified by:
getInitialPacPosition
in interfaceGame
-
getInitialGhostsPosition
public int getInitialGhostsPosition()- Specified by:
getInitialGhostsPosition
in interfaceGame
-
getNumberOfNodes
public int getNumberOfNodes()- Specified by:
getNumberOfNodes
in interfaceGame
-
getX
public int getX(int index) -
getY
public int getY(int index) -
getPillIndex
public int getPillIndex(int nodeIndex)- Specified by:
getPillIndex
in interfaceGame
-
getPowerPillIndex
public int getPowerPillIndex(int nodeIndex)- Specified by:
getPowerPillIndex
in interfaceGame
-
getNeighbour
public int getNeighbour(int nodeIndex, int direction)- Specified by:
getNeighbour
in interfaceGame
-
getPillIndices
public int[] getPillIndices()- Specified by:
getPillIndices
in interfaceGame
-
getPowerPillIndices
public int[] getPowerPillIndices()- Specified by:
getPowerPillIndices
in interfaceGame
-
getJunctionIndices
public int[] getJunctionIndices()- Specified by:
getJunctionIndices
in interfaceGame
-
isJunction
public boolean isJunction(int nodeIndex)- Specified by:
isJunction
in interfaceGame
-
getNextEdibleGhostScore
public int getNextEdibleGhostScore()- Specified by:
getNextEdibleGhostScore
in interfaceGame
-
getNumActivePills
public int getNumActivePills()- Specified by:
getNumActivePills
in interfaceGame
-
getNumActivePowerPills
public int getNumActivePowerPills()- Specified by:
getNumActivePowerPills
in interfaceGame
-
getPillIndicesActive
public int[] getPillIndicesActive()- Specified by:
getPillIndicesActive
in interfaceGame
-
getPowerPillIndicesActive
public int[] getPowerPillIndicesActive()- Specified by:
getPowerPillIndicesActive
in interfaceGame
-
getNumNeighbours
public int getNumNeighbours(int nodeIndex)- Specified by:
getNumNeighbours
in interfaceGame
-
getPossiblePacManDirs
public int[] getPossiblePacManDirs(boolean includeReverse)- Specified by:
getPossiblePacManDirs
in interfaceGame
-
getPossibleGhostDirs
public int[] getPossibleGhostDirs(int whichGhost)- Specified by:
getPossibleGhostDirs
in interfaceGame
-
getPossibleDirs
public int[] getPossibleDirs(int curLoc, int curDir, boolean includeReverse)- Specified by:
getPossibleDirs
in interfaceGame
-
getNextPacManDir
- Specified by:
getNextPacManDir
in interfaceGame
-
getNextGhostDir
- Specified by:
getNextGhostDir
in interfaceGame
-
getPathDistance
public int getPathDistance(int from, int to)- Specified by:
getPathDistance
in interfaceGame
-
getEuclideanDistance
public double getEuclideanDistance(int from, int to)- Specified by:
getEuclideanDistance
in interfaceGame
-
getManhattanDistance
public int getManhattanDistance(int from, int to)- Specified by:
getManhattanDistance
in interfaceGame
-
getPath
public int[] getPath(int from, int to) -
getGhostPath
public int[] getGhostPath(int whichGhost, int to)- Specified by:
getGhostPath
in interfaceGame
-
getTarget
-
getGhostTarget
public int getGhostTarget(int whichGhost, int[] targets, boolean nearest)- Specified by:
getGhostTarget
in interfaceGame
-
getGhostPathDistance
public int getGhostPathDistance(int whichGhost, int to)- Specified by:
getGhostPathDistance
in interfaceGame
-