megamek.common.util
Class BoardUtilities

java.lang.Object
  extended by megamek.common.util.BoardUtilities

public class BoardUtilities
extends java.lang.Object


Nested Class Summary
protected static class BoardUtilities.Point
           
 
Constructor Summary
BoardUtilities()
           
 
Method Summary
protected static void addCliffs(IBoard board, int modifier)
           
static void addCraters(IBoard board, int minRadius, int maxRadius, int minCraters, int maxCraters)
          add a crater to the board
static void addRiver(IBoard board, java.util.HashMap<IHex,BoardUtilities.Point> reverseHex)
          Adds an River to the map (if the map is at least 5x5 hexes big).
static void addWeatherConditions(IBoard board, int weatherCond, int windCond)
           
static IBoard combine(int width, int height, int sheetWidth, int sheetHeight, IBoard[] boards, int medium)
          Combines one or more boards into one huge megaboard!
protected static void copyBoardInto(IHex[] dest, int destWidth, int x, int y, IBoard copied)
          Copies the data of another board into given array of Hexes, offset by the specified x and y.
static int craterProfile(double x, int scale)
          The profile of a crater: interior is exp-function, exterior cos function.
protected static void cutSteps(int hilliness, int width, int height, int[][] elevationMap)
          one of the landscape generation algorithms
protected static void diagMid(BoardUtilities.Point p, int d1, int d2, int delta, int size, int[][] elevationMap)
          calculates the diagonal middlepoints with new values
static void flip(IBoard board, boolean horiz, boolean vert)
          Flips the board around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West).
static void generateElevation(int hilliness, int width, int height, int range, int invertProb, int invertNegative, int[][] elevationMap, int algorithm)
          Generates the elevations
static void generateMountain(IBoard board, int width, Coords centre, int height, int capStyle)
           
static IBoard generateRandom(MapSettings mapSettings)
          Generates a Random Board
protected static void markRect(int x1, int x2, int inc, int[][] elevationMap, int height)
          Helper function for the map generator increased a heightmap my a given value
protected static void markSides(BoardUtilities.Point p1, BoardUtilities.Point p2, int upperInc, int lowerInc, int[][] elevationMap, int height)
          Helper function for map generator inreases all of one side and decreased on other side
protected static int middleValue(int a, int b, int c, int delta)
          calculates the arithmetic medium of 3 values and add random value in range of delta.
protected static int middleValue(int a, int b, int c, int d, int delta)
          calculates the arithmetic medium of 4 values and add random value in range of delta.
protected static void midPoint(int hilliness, int width, int height, int[][] elevationMap)
          midpoint algorithm for landscape generartion
protected static void midPointStep(double fracdim, int size, int delta, int[][] elevationMap, int step, boolean newBorder)
          Helper function for landscape generation
protected static void placeSomeTerrain(IBoard board, int terrainType, int probMore, int minHexes, int maxHexes, java.util.HashMap<IHex,BoardUtilities.Point> reverseHex, boolean exclusive)
          Places randomly some connected Woods.
protected static void postProcessDeepFreeze(IHex[] hexSet, int modifier)
          Converts water hexes to ice hexes.
protected static void postProcessDrought(IHex[] hexSet, int modifier)
          Dries up all bodies of water by 1-3 levels. dried up water becomes swamp then rough
protected static void postProcessFlood(IHex[] hexSet, int modifier)
          Flood negative hex levels Shoreline / salt marshes effect Works best with more elevation
protected static void postProcessForestFire(IHex[] hexSet, int modifier)
          Burning woods, with chance to be burnt down already
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoardUtilities

public BoardUtilities()
Method Detail

combine

public static IBoard combine(int width,
                             int height,
                             int sheetWidth,
                             int sheetHeight,
                             IBoard[] boards,
                             int medium)
Combines one or more boards into one huge megaboard!

Parameters:
width - the width of each individual board, before the combine
height - the height of each individual board, before the combine
sheetWidth - how many sheets wide the combined map is
sheetHeight - how many sheets tall the combined map is
boards - an array of the boards to be combined

copyBoardInto

protected static void copyBoardInto(IHex[] dest,
                                    int destWidth,
                                    int x,
                                    int y,
                                    IBoard copied)
Copies the data of another board into given array of Hexes, offset by the specified x and y.


generateRandom

public static IBoard generateRandom(MapSettings mapSettings)
Generates a Random Board

Parameters:
width - The width of the generated Board.
height - The height of the gernerated Board.
steps - how often the iterative method should be repeated

placeSomeTerrain

protected static void placeSomeTerrain(IBoard board,
                                       int terrainType,
                                       int probMore,
                                       int minHexes,
                                       int maxHexes,
                                       java.util.HashMap<IHex,BoardUtilities.Point> reverseHex,
                                       boolean exclusive)
Places randomly some connected Woods.

Parameters:
probHeavy - The probability that a wood is a heavy wood (in %).
maxWoods - Maximum Number of Woods placed.

addCraters

public static void addCraters(IBoard board,
                              int minRadius,
                              int maxRadius,
                              int minCraters,
                              int maxCraters)
add a crater to the board


craterProfile

public static int craterProfile(double x,
                                int scale)
The profile of a crater: interior is exp-function, exterior cos function.

Parameters:
x - The x value of the function. range 0..1. 0=center of crater. 1=border of outer wall.
scale - Apply this scale before returning the result (recommend instead of afterwards scale, cause this way the intern floating values are scaled, instead of int result).
Returns:
The height of the crater at the position x from center. Unscaled, the results are between -0.5 and 1 (that means, if no scale is applied -1, 0 or 1).

addRiver

public static void addRiver(IBoard board,
                            java.util.HashMap<IHex,BoardUtilities.Point> reverseHex)
Adds an River to the map (if the map is at least 5x5 hexes big). The river has an width of 1-3 hexes (everything else is no more a river). The river goes from one border to another. Nor Params, no results.


postProcessFlood

protected static void postProcessFlood(IHex[] hexSet,
                                       int modifier)
Flood negative hex levels Shoreline / salt marshes effect Works best with more elevation


postProcessDeepFreeze

protected static void postProcessDeepFreeze(IHex[] hexSet,
                                            int modifier)
Converts water hexes to ice hexes. Works best with snow&ice theme.


postProcessForestFire

protected static void postProcessForestFire(IHex[] hexSet,
                                            int modifier)
Burning woods, with chance to be burnt down already


postProcessDrought

protected static void postProcessDrought(IHex[] hexSet,
                                         int modifier)
Dries up all bodies of water by 1-3 levels. dried up water becomes swamp then rough


addCliffs

protected static void addCliffs(IBoard board,
                                int modifier)

addWeatherConditions

public static void addWeatherConditions(IBoard board,
                                        int weatherCond,
                                        int windCond)

generateElevation

public static void generateElevation(int hilliness,
                                     int width,
                                     int height,
                                     int range,
                                     int invertProb,
                                     int invertNegative,
                                     int[][] elevationMap,
                                     int algorithm)
Generates the elevations

Parameters:
hilliness - The Hilliness
width - The Width of the map.
height - The Height of the map.
range - Max difference betweenn highest and lowest level.
invertProb - Probability for the invertion of the map (0..100)
invertNegate - If 1, invert negative hexes, else do nothing
elevationMap - here is the result stored

generateMountain

public static void generateMountain(IBoard board,
                                    int width,
                                    Coords centre,
                                    int height,
                                    int capStyle)

flip

public static void flip(IBoard board,
                        boolean horiz,
                        boolean vert)
Flips the board around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West). The dimensions of the board will remain the same, but the terrain of the hexes will be swiched.

Parameters:
horiz - - a boolean value that, if true, indicates that the board is being flipped North-for-South.
vert - - a boolean value that, if true, indicates that the board is being flipped East-for-West.

cutSteps

protected static void cutSteps(int hilliness,
                               int width,
                               int height,
                               int[][] elevationMap)
one of the landscape generation algorithms


markRect

protected static void markRect(int x1,
                               int x2,
                               int inc,
                               int[][] elevationMap,
                               int height)
Helper function for the map generator increased a heightmap my a given value


markSides

protected static void markSides(BoardUtilities.Point p1,
                                BoardUtilities.Point p2,
                                int upperInc,
                                int lowerInc,
                                int[][] elevationMap,
                                int height)
Helper function for map generator inreases all of one side and decreased on other side


midPoint

protected static void midPoint(int hilliness,
                               int width,
                               int height,
                               int[][] elevationMap)
midpoint algorithm for landscape generartion


midPointStep

protected static void midPointStep(double fracdim,
                                   int size,
                                   int delta,
                                   int[][] elevationMap,
                                   int step,
                                   boolean newBorder)
Helper function for landscape generation


diagMid

protected static void diagMid(BoardUtilities.Point p,
                              int d1,
                              int d2,
                              int delta,
                              int size,
                              int[][] elevationMap)
calculates the diagonal middlepoints with new values

Parameters:
p - Starting point.

middleValue

protected static int middleValue(int a,
                                 int b,
                                 int c,
                                 int delta)
calculates the arithmetic medium of 3 values and add random value in range of delta.


middleValue

protected static int middleValue(int a,
                                 int b,
                                 int c,
                                 int d,
                                 int delta)
calculates the arithmetic medium of 4 values and add random value in range of delta.