private Object getNextKnightMove(mxAnalysisGraph aGraph, int xDim, int yDim, int xCoord, int yCoord, ArrayList<Object> resultPath)
	{
		Object[] possibleMoves = getKnightMoveVertexes(aGraph, xDim, yDim, xCoord, yCoord);
		//get the position with minimum possible moves
		int minMoveNum = 9;
		float biggestDistance = 0;
		Object currVertex = null;
		mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
		mxGraphView view = aGraph.getGraph().getView();
		
		for (int i = 0; i < possibleMoves.length; i++)
		{
			int currValue = (int) costFunction.getCost(new mxCellState(view, possibleMoves[i], null));
			int[] currCoords = getVertexGridCoords(xDim, yDim, currValue);
			int currMoveNum = getPossibleKnightMoveCount(aGraph, xDim, yDim, currCoords[0], currCoords[1]);
			float currDistance = getDistanceFromGridCenter(xDim, yDim, currValue);

			if ((currMoveNum < minMoveNum || (currMoveNum == minMoveNum && currDistance > biggestDistance))
					&& !resultPath.contains(possibleMoves[i]))
			{
				biggestDistance = currDistance;
				minMoveNum = currMoveNum;
				currVertex = possibleMoves[i];
			}
		}
		return currVertex;
	};