if(hexes.size() == 0) return null;
    private static Coords tryToBuildBridge(IBoard board, Coords start, int direction) {        if(!board.contains(start))return null;        Vector<Coords> hexes = new Vector(7);        Coords end = null;        Coords next = start.translated(direction);        while(hexes.size() < 6) {            if(!board.contains(next)) {                //offboard, why bother?                break;            }            if(!hexNeedsBridge(board.getHex(next))) {                end = next;                break;            }            hexes.add(next);            next = next.translated(direction);        }        if(end != null) {            //got start and end, can we make a bridge?            int elev1 = board.getHex(start).getElevation();            int elev2 = board.getHex(end).getElevation();            int elevBridge = board.getHex(end).terrainLevel(Terrains.BRIDGE);            if(elevBridge >=0) {                if(Math.abs(elev2 + elevBridge - elev1) > 2)                    return null;                elev1 = elev2 + elevBridge;            } else {                if(Math.abs(elev1-elev2) > 4) {                    //nobody could use the bridge, give up                    return null;                }            elev1 = (elev1 + elev2) / 2;            }            //build the bridge            int exits = (1<<direction) | (1<<((direction + 3) %6));            for(Enumeration<Coords> e=hexes.elements();e.hasMoreElements();) {                Coords c = e.nextElement();                addBridge(board.getHex(c), exits, elev1);            }            connectHexes(board, start, hexes.firstElement(), 1);            connectHexes(board, end, hexes.lastElement(), 1);        }        return end;    }