JTP
Class Challenge

java.lang.Object
  extended by JTP.Challenge

public class Challenge
extends Object

Generates levels for one and two-player challenge modes.

Author:
V.Termanis

Constructor Summary
Challenge()
           
 
Method Summary
static Level genLevel(Dimension grid, Point offset, int tileCount, int maxTileHeight, boolean cooperative, Random r)
          Generates a new level with the given attributes.
static LevelSet genSet(int numberOfLevels, int minTileCount, int minTileCountIncrement, Dimension grid, Point offset, int maxTileHeight, int forceGenRetries, boolean cooperative)
          Generates a new set of levels with the given attributes.
static LevelSet genSet(int numberOfLevels, int minTileCount, int minTileCountIncrement, int gridSize, int offset, int maxTileHeight, int forceGenRetries, boolean cooperative)
          Generates a new set of levels with the given attributes and a square grid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Challenge

public Challenge()
Method Detail

genSet

public static LevelSet genSet(int numberOfLevels,
                              int minTileCount,
                              int minTileCountIncrement,
                              Dimension grid,
                              Point offset,
                              int maxTileHeight,
                              int forceGenRetries,
                              boolean cooperative)
                       throws IllegalArgumentException
Generates a new set of levels with the given attributes.

Parameters:
numberOfLevels - the number of levels to generate
minTileCount - number of tiles required in first level
minTileCountIncrement - increase of tiles per level. For example level 10 would have minTileCount + (minTileCountIncrement * 9) tiles.
grid - width and height of all levels
offset - from outside of grid which is not to be used. For example if the grid is 15x15 and the offset has been specified as 2x2 then only the 11x11 area in the middle of the 15x15 grid will be used
maxTileHeight - maximum height of any pile
forceGenRetries - number of times to regenerate level if it does not have enough tiles (this can happen if the current position is surrounded by piles of height maxTileHeight.
cooperative - if set, a two-player levelset will be generated
Returns:
the generated levelset
Throws:
IllegalArgumentException - if offset is too large for the specified grid.

genSet

public static LevelSet genSet(int numberOfLevels,
                              int minTileCount,
                              int minTileCountIncrement,
                              int gridSize,
                              int offset,
                              int maxTileHeight,
                              int forceGenRetries,
                              boolean cooperative)
Generates a new set of levels with the given attributes and a square grid.

Parameters:
numberOfLevels - the number of levels to generate
minTileCount - number of tiles required in first level
minTileCountIncrement - increase of tiles per level. For example level 10 would have minTileCount + (minTileCountIncrement * 9) tiles.
gridSize - width and height of all levels
offset - from outside of grid which is not to be used. For example if the grid is 15x15 and the offset has been specified as 2 then only the 11x11 area in the middle of the 15x15 grid will be used
maxTileHeight - maximum height of any pile
forceGenRetries - number of times to regenerate level if it does not have enough tiles (this can happen if the current position is surrounded by piles of height maxTileHeight.
cooperative - if set, a two-player levelset will be generated
Returns:
the generated levelset
Throws:
IllegalArgumentException - if offset is too large for the specified grid.

genLevel

public static Level genLevel(Dimension grid,
                             Point offset,
                             int tileCount,
                             int maxTileHeight,
                             boolean cooperative,
                             Random r)
Generates a new level with the given attributes.

Parameters:
grid - width and height of the level
offset - from outside of grid which is not to be used. For example if the grid is 15x15 and the offset has been specified as 2 then only the 11x11 area in the middle of the 15x15 grid will be used
tileCount - number of tiles the level should have. Note: The level can end up with less than the specified number of tiles. This is not very likely though, unless tileCount is very large and and maxTileHeight fairly low.
maxTileHeight - maximum height of any pile
cooperative - if set, a two-player level will be generated
r - instance of Random required to use Random.nextGaussian() method
Returns:
the generated level