本文整理汇总了Java中pacman.game.Constants.MOVE.NEUTRAL属性的典型用法代码示例。如果您正苦于以下问题:Java MOVE.NEUTRAL属性的具体用法?Java MOVE.NEUTRAL怎么用?Java MOVE.NEUTRAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pacman.game.Constants.MOVE
的用法示例。
在下文中一共展示了MOVE.NEUTRAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawPacMan
/**
* Draw pac man.
*/
private void drawPacMan()
{
int pacLoc=game.getPacmanCurrentNodeIndex();
MOVE tmpLastPacManMove=game.getPacmanLastMoveMade();
double halfMag = 0.5*MAG;
int width = (int) (images.getPacMan(lastPacManMove,time).getWidth() * halfMag);
int height = (int) (images.getPacMan(lastPacManMove,time).getHeight() * halfMag);
if(tmpLastPacManMove!=MOVE.NEUTRAL)
lastPacManMove=tmpLastPacManMove;
bufferGraphics.drawImage(images.getPacMan(lastPacManMove,time), (int)(game.getNodeXCood(pacLoc)*MAG-1*halfMag), (int) (game.getNodeYCood(pacLoc)*MAG+3*halfMag), width, height, null);
}
示例2: _correctPacManDir
/**
* _correct pac man dir.
*
* @param direction the direction
* @return the mOVE
*/
private MOVE _correctPacManDir(MOVE direction)
{
Node node=currentMaze.graph[pacman.currentNodeIndex];
//direction is correct, return it
if(node.neighbourhood.containsKey(direction))
return direction;
else
{
//try to use previous direction (i.e., continue in the same direction)
if(node.neighbourhood.containsKey(pacman.lastMoveMade))
return pacman.lastMoveMade;
//else stay put
else
return MOVE.NEUTRAL;
}
}
示例3: _reverseGhosts
private boolean _reverseGhosts(EnumMap<GHOST,MOVE> moves,boolean force)
{
boolean reversed=false;
boolean globalReverse=false;
if(Math.random()<GHOST_REVERSAL)
globalReverse=true;
for(Entry<GHOST,MOVE> entry : moves.entrySet())
{
Ghost ghost=ghosts.get(entry.getKey());
if(currentLevelTime>1 && ghost.lairTime==0 && ghost.lastMoveMade!=MOVE.NEUTRAL)
{
if(force || (powerPillWasEaten || globalReverse))
{
ghost.lastMoveMade=ghost.lastMoveMade.opposite();
ghost.currentNodeIndex=currentMaze.graph[ghost.currentNodeIndex].neighbourhood.get(ghost.lastMoveMade);
reversed=true;
timeOfLastGlobalReversal = totalTime;
}
}
}
return reversed;
}
示例4: getSmartmove
/**
* direction moves modified to avoid jam situations
* returns direction on junctions
* returns direction on tunnels if direction is a possible move
* returns last move on tunnels if direction it's not a possible move
*/
public MOVE getSmartmove(int pacmanLocation, MOVE direction) {
if (isJunction(pacmanLocation)) //returns direction on junctions
return direction;
else if (getNeighbour(pacmanLocation, direction) != -1) //returns direction on tunnels if direction is a possible move
return direction;
else { //returns last move on tunnels if direction it's not a possible move
if (getNeighbour(pacmanLocation, getPacmanLastMoveMade()) != -1) // 'I' tunnel
return getPacmanLastMoveMade();
else if (getNeighbour(pacmanLocation, getPacmanLastMoveMade().L90()) != -1) // 'L' tunnel 90º left
return getPacmanLastMoveMade().L90();
else if (getNeighbour(pacmanLocation, getPacmanLastMoveMade().R90()) != -1) // 'L' tunnel 90º right
return getPacmanLastMoveMade().R90();
else
return MOVE.NEUTRAL; //unknown situation
}
}
示例5: atacar
/**
*Mirar si se puede llegar al fantasma comible mas cercano
*Antes de que pueda llegar ningun fantasma no comible a el
*Si tal, ir a comerselo, si no, llamada a farmear
*/
public MOVE atacar(){
boolean atk = true;
Ghost g = getClosestEdibleGhost(getPacmanCurrentNodeIndex());
if (g == null)
return MOVE.NEUTRAL;
int closestg = g.currentNodeIndex;
double distpmg = getDistance(getPacmanCurrentNodeIndex(), closestg, DM.PATH);
for (Ghost ghost : this.ghosts.values())
{
if (!ghost.isEdible() && !ghost.isInLair())
{
if(getDistance(closestg, ghost.currentNodeIndex, DM.PATH) < distpmg)
atk = false;
}
}
if(atk)
return getNextMoveTowardsTarget(getPacmanCurrentNodeIndex(), closestg, DM.PATH);
else{
return MOVE.NEUTRAL;
}
}
示例6: executeAndGetMove
public MOVE executeAndGetMove(Game g){
Node tn = this.execute(g);
if (tn == null)
return MOVE.NEUTRAL;
if (tn.children.size() != 0){
System.out.println();
}
return ((TerminalNode) this.execute(g)).getMove(g);
}
示例7: getGhost
public BufferedImage getGhost(GHOST ghost,MOVE move,int time)
{
if(move==MOVE.NEUTRAL)
return ghosts.get(ghost).get(MOVE.UP)[(time%6)/3];
else
return ghosts.get(ghost).get(move)[(time%6)/3];
}
示例8: _updatePacMan
/**
* _update pac man.
*
* @param move the move
*/
private void _updatePacMan(MOVE move)
{
pacman.lastMoveMade=_correctPacManDir(move);
pacman.currentNodeIndex=pacman.lastMoveMade == MOVE.NEUTRAL ? pacman.currentNodeIndex :
currentMaze.graph[pacman.currentNodeIndex].neighbourhood.get(pacman.lastMoveMade);
}
示例9: doesGhostRequireAction
/**
* If in lair (getLairTime(-)>0) or if not at junction.
*
* @param ghostType the ghost type
* @return true, if successful
*/
public boolean doesGhostRequireAction(GHOST ghostType)
{
//inlcude neutral here for the unique case where the ghost just left the lair
return ((isJunction(ghosts.get(ghostType).currentNodeIndex) || (ghosts.get(ghostType).lastMoveMade==MOVE.NEUTRAL) && ghosts.get(ghostType).currentNodeIndex==currentMaze.initialGhostNodeIndex)
&& (ghosts.get(ghostType).edibleTime==0 || ghosts.get(ghostType).edibleTime%GHOST_SPEED_REDUCTION!=0));
}
示例10: getDirectionTowardsClosestEdibleGhost
/**
* Returns the direction towards the closest edible ghost (NEUTRAL if no edible ghosts avaiable)
*/
public MOVE getDirectionTowardsClosestEdibleGhost(int pacmanNode){
MOVE ret = MOVE.NEUTRAL;
Ghost g = getClosestEdibleGhost(pacmanNode);
if (g != null)
ret = getNextMoveTowardsTarget(pacmanNode, g.currentNodeIndex, DM.PATH);
return ret;
}
示例11: getDirectionAwayFromClosestNonEdibleGhost
/**
* Returns the movement opposed to the direction of the closest non edible ghost
*/
public MOVE getDirectionAwayFromClosestNonEdibleGhost(int pacmanNode){
MOVE ret = MOVE.NEUTRAL;
Ghost g = getClosestNonEdibleGhost(pacmanNode);
if (g != null)
ret = getNextMoveAwayFromTarget(pacmanNode, g.currentNodeIndex, DM.PATH);
return ret;
}
示例12: getDirectionTowardsClosestPowerPill
/**
* Returns the movement towards the closest PowerPill
*/
public MOVE getDirectionTowardsClosestPowerPill(int pacmanNode){
MOVE ret = MOVE.NEUTRAL;
int cpp = getClosestPowerPill(pacmanNode);
if (cpp != -1)
ret = getNextMoveTowardsTarget(pacmanNode, cpp, DM.PATH);
return ret;
}
示例13: getDirectionTowardsClosestPill
/**
* Returns the movement towards the closest Pill
*/
public MOVE getDirectionTowardsClosestPill(int pacmanNode){
MOVE ret = MOVE.NEUTRAL;
int cpp = getClosestPill(pacmanNode);
if (cpp != -1)
ret = getNextMoveTowardsTarget(pacmanNode, cpp, DM.PATH);
return ret;
}
示例14: huir
/**Mirar powerpill mas cercana, su distancia de pacman a ella ppd
*Si las distancias son mayores desde todos los fantasmas a la PP que la de pacman, ir a por la PP
*Si no, huir en la direccion por la que se tarde mas en llegar a un fantasma
*/
public MOVE huir(){
boolean go2pp = true;
int closestpp = getClosestPowerPill(getPacmanCurrentNodeIndex());
if (closestpp < 0) {
Ghost nonEdibleGhost = getClosestNonEdibleGhost(getPacmanCurrentNodeIndex());
if (nonEdibleGhost != null)
return getNextMoveAwayFromTarget(getPacmanCurrentNodeIndex(), getClosestNonEdibleGhost(getPacmanCurrentNodeIndex()).currentNodeIndex, DM.PATH);
else
return MOVE.NEUTRAL;
}
double distpmpp = getDistance(getPacmanCurrentNodeIndex(), closestpp, DM.PATH); //returns double with different DMs
for (Ghost ghost : this.ghosts.values())
{
if (!ghost.isEdible() && !ghost.isInLair())
{
if((int)getDistance(closestpp, ghost.currentNodeIndex, DM.PATH) < distpmpp)
go2pp = false;
}
}
if(go2pp)
return getNextMoveTowardsTarget(getPacmanCurrentNodeIndex(), closestpp, DM.PATH);
else{
return getNextMoveAwayFromTarget(getPacmanCurrentNodeIndex(), getClosestNonEdibleGhost(getPacmanCurrentNodeIndex()).currentNodeIndex, DM.PATH);
}
}
示例15: farmear
/**
* Ir a por pill mas cercana a la que no llegen antes los fantasmas antes, si no puede llegar a ninguna se aleja de ellos
*/
public MOVE farmear(){
boolean go2p = true;
int closestp = getClosestPill(getPacmanCurrentNodeIndex());
if (closestp < 0) {
int closestpp = getClosestPowerPill(getPacmanCurrentNodeIndex());
return getNextMoveTowardsTarget(getPacmanCurrentNodeIndex(), closestpp, DM.PATH);
}
double distpmp = getDistance(getPacmanCurrentNodeIndex(), closestp, DM.PATH);
for (Ghost ghost : this.ghosts.values())
{
if (!ghost.isEdible() && !ghost.isInLair())
{
if(getDistance(closestp, ghost.currentNodeIndex, DM.PATH) < distpmp)
go2p = false;
}
}
if(go2p)
return getNextMoveTowardsTarget(getPacmanCurrentNodeIndex(), closestp, DM.PATH);
else{
return MOVE.NEUTRAL;
}
}