Package horizons :: Package util :: Module random_map
[hide private]
[frames] | no frames]

Module random_map

source code

Functions [hide private]
 
create_random_island(map_db, island_id, id_string)
Creates a random island as sqlite db.
source code
 
_simplify_seed(seed)
Return the simplified seed value.
source code
 
generate_random_map(seed, map_size, water_percent, max_island_size, preferred_island_size, island_size_deviation)
Generates a random map.
source code
 
generate_random_seed(seed) source code
 
generate_map_from_seed(seed)
Generates a random map with the given seed and default parameters.
source code
 
generate_huge_map_from_seed(seed)
Same as generate_map_from_seed, but making it as big as it is still reasonable
source code
Variables [hide private]
  _random_island_id_template = "random:${creation_method}:${widt...
  _random_island_id_regexp = r"^random:([0-9]+):([0-9]+):([0-9]+...
Function Details [hide private]

create_random_island(map_db, island_id, id_string)

source code 

Creates a random island as sqlite db. It is rather primitive; it places shapes on the dict. The coordinates of tiles will be 0 <= x < width and 0 <= y < height

Parameters:
  • id_string - random island id string

_simplify_seed(seed)

source code 

Return the simplified seed value. The goal of this is to make it easier for users to convey the seeds orally.

This function also makes sure its return value fits into a 32bit integer. That is necessary because otherwise the hash of the value could be different between 32 and 64 bit python interpreters. That would cause a map with seed X to be different depending on the platform which we don't want to happen.

generate_random_map(seed, map_size, water_percent, max_island_size, preferred_island_size, island_size_deviation)

source code 

Generates a random map.

Parameters:
  • seed - random number generator seed
  • map_size - maximum map side length
  • water_percent - minimum percent of map covered with water
  • max_island_size - maximum island side length
  • preferred_island_size - mean of island side lengths
  • island_size_deviation - deviation of island side lengths
Returns:
filename of the SQLite database containing the map

generate_map_from_seed(seed)

source code 

Generates a random map with the given seed and default parameters.

Parameters:
  • seed - random number generator seed
Returns:
filename of the SQLite database containing the map

Variables Details [hide private]

_random_island_id_template

Value:
"random:${creation_method}:${width}:${height}:${seed}:${island_x}:${is\
land_y}"

_random_island_id_regexp

Value:
r"^random:([0-9]+):([0-9]+):([0-9]+):([\-]?[0-9]+):([\-]?[0-9]+):([\-]\
?[0-9]+)$"