double maxTerrains = Math.max(org.terrainsPresent(), com.terrainsPresent()); double matches = 0;
double maxTerrains = Math.max(org.terrainsPresent(), com.terrainsPresent()) + 1.0; double matches = 1.0;
    private double baseMatch(Hex org, Hex com) {        double elevation;        double terrain;        double theme;                // check elevation        if (com.getElevation() == Terrain.WILDCARD) {            elevation = 1.0;        } else {            elevation = 1.01 / (Math.abs(org.getElevation() - com.getElevation()) + 1.01);        }                // check terrain        double maxTerrains = Math.max(org.terrainsPresent(), com.terrainsPresent());        double matches = 0;        for (int i = 0; i < Terrain.SIZE; i++) {            Terrain cTerr = com.getTerrain(i);            Terrain oTerr = org.getTerrain(i);            if (cTerr == null || oTerr == null) {                continue;            }            double thisMatch = 0;                        if (cTerr.getLevel() == Terrain.WILDCARD) {                thisMatch = 1.0;            } else {                thisMatch = 1.0 / (Math.abs(oTerr.getLevel() - cTerr.getLevel()) + 1.0);            }            // without exit match, terrain counts... um, half?            if (cTerr.hasExitsSpecified() && oTerr.getExits() != cTerr.getExits()) {                thisMatch *= 0.5;            }            // add up match value            matches += thisMatch;        }        if (maxTerrains == 0) {            terrain = 1.0;        } else {            terrain = matches / maxTerrains;        }                // check theme        if (com.getTheme() == org.getTheme() || (com.getTheme() != null && com.getTheme().equalsIgnoreCase(org.getTheme()))) {            theme = 1.0;        } else {            // also don't throw a match entirely out because the theme is off            theme = 0.0001;        }                return elevation * terrain * theme;    }