本文整理匯總了Java中pacman.game.Constants.MOVE.values方法的典型用法代碼示例。如果您正苦於以下問題:Java MOVE.values方法的具體用法?Java MOVE.values怎麽用?Java MOVE.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pacman.game.Constants.MOVE
的用法示例。
在下文中一共展示了MOVE.values方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createGraph
import pacman.game.Constants.MOVE; //導入方法依賴的package包/類
public void createGraph(Node[] nodes)
{
graph=new N[nodes.length];
//create graph
for(int i=0;i<nodes.length;i++)
graph[i]=new N(nodes[i].nodeIndex);
//add neighbours
for(int i=0;i<nodes.length;i++)
{
EnumMap<MOVE,Integer> neighbours=nodes[i].neighbourhood;
MOVE[] moves=MOVE.values();
for(int j=0;j<moves.length;j++)
if(neighbours.containsKey(moves[j]))
graph[i].adj.add(new E(graph[neighbours.get(moves[j])],moves[j],1));
}
}
示例2: getMoveToMakeToReachDirectNeighbour
import pacman.game.Constants.MOVE; //導入方法依賴的package包/類
/**
* Method that returns the direction to take given a node index and an index of a neighbouring
* node. Returns null if the neighbour is invalid.
*
* @param currentNodeIndex The current node index.
* @param neighbourNodeIndex The direct neighbour (node index) of the current node.
* @return the move to make to reach direct neighbour
*/
public MOVE getMoveToMakeToReachDirectNeighbour(int currentNodeIndex,int neighbourNodeIndex)
{
for(MOVE move : MOVE.values())
{
if(currentMaze.graph[currentNodeIndex].neighbourhood.containsKey(move)
&& currentMaze.graph[currentNodeIndex].neighbourhood.get(move)==neighbourNodeIndex)
{
return move;
}
}
return null;
}
示例3: computeShortestPaths
import pacman.game.Constants.MOVE; //導入方法依賴的package包/類
public void computeShortestPaths()
{
MOVE[] moves=MOVE.values();
for(int i=0;i<paths.length;i++)
{
if(i==jctId)
paths[i].put(MOVE.NEUTRAL,new int[]{});
else
{
int distance=Integer.MAX_VALUE;
int[] path=null;
for(int j=0;j<moves.length;j++)
{
if(paths[i].containsKey(moves[j]))
{
int[] tmp=paths[i].get(moves[j]);
if(tmp.length<distance)
{
distance=tmp.length;
path=tmp;
}
}
}
paths[i].put(MOVE.NEUTRAL,path);
}
}
}
示例4: Node
import pacman.game.Constants.MOVE; //導入方法依賴的package包/類
public Node(int nodeIndex,int x,int y,int pillIndex,int powerPillIndex,int[] _neighbourhood)
{
this.nodeIndex=nodeIndex;
this.x=x;
this.y=y;
this.pillIndex=pillIndex;
this.powerPillIndex=powerPillIndex;
MOVE[] moves=MOVE.values();
for(int i=0;i<_neighbourhood.length;i++)
if(_neighbourhood[i]!=-1)
neighbourhood.put(moves[i],_neighbourhood[i]);
numNeighbouringNodes=neighbourhood.size();
for(int i=0;i<moves.length;i++)
if(neighbourhood.containsKey(moves[i]))
{
EnumMap<MOVE, Integer> tmp=new EnumMap<MOVE, Integer>(neighbourhood);
tmp.remove(moves[i]);
allNeighbourhoods.put(moves[i].opposite(),tmp);
}
allNeighbourhoods.put(MOVE.NEUTRAL,neighbourhood);
int[] neighbouringNodes=new int[numNeighbouringNodes];
MOVE[] possibleMoves=new MOVE[numNeighbouringNodes];
int index=0;
for(int i=0;i<moves.length;i++)
if(neighbourhood.containsKey(moves[i]))
{
neighbouringNodes[index]=neighbourhood.get(moves[i]);
possibleMoves[index]=moves[i];
index++;
}
for(int i=0;i<moves.length;i++)//check all moves
{
if(neighbourhood.containsKey(moves[i].opposite()))//move is part of neighbourhood
{
int[] tmpNeighbouringNodes=new int[numNeighbouringNodes-1];
MOVE[] tmpPossibleMoves=new MOVE[numNeighbouringNodes-1];
index=0;
for(int j=0;j<moves.length;j++)//add all moves to neighbourhood except the one above
{
if(moves[j]!=moves[i].opposite() && neighbourhood.containsKey(moves[j]))
{
tmpNeighbouringNodes[index]=neighbourhood.get(moves[j]);
tmpPossibleMoves[index]=moves[j];
index++;
}
}
allNeighbouringNodes.put(moves[i],tmpNeighbouringNodes);
allPossibleMoves.put(moves[i],tmpPossibleMoves);
}
}
allNeighbouringNodes.put(MOVE.NEUTRAL,neighbouringNodes);
allPossibleMoves.put(MOVE.NEUTRAL,possibleMoves);
}