当前位置: 首页>>代码示例>>Java>>正文


Java MOVE.values方法代码示例

本文整理汇总了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));	
	}
}
 
开发者ID:hecoding,项目名称:Pac-Man,代码行数:20,代码来源:AStar.java

示例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;
}
 
开发者ID:hecoding,项目名称:Pac-Man,代码行数:22,代码来源:Game.java

示例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);
		}
	}
}
 
开发者ID:hecoding,项目名称:Pac-Man,代码行数:32,代码来源:PathsCache.java

示例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);
}
 
开发者ID:hecoding,项目名称:Pac-Man,代码行数:67,代码来源:Node.java


注:本文中的pacman.game.Constants.MOVE.values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。