redeclipse.upm module

class redeclipse.upm.UnusedPositionManager(world_size, mirror=1, noclip=False)[source]

Bases: object

Class for maintaining a quick-lookup list of which 8x8x8 cubes are in-use

This is closely tied to our prefab model

endcap(debug=False, possible_endcaps=[])[source]

Is the position within the bounds of the map.

Parameters:position (redeclipse.vector.CoarseVector) – A vector representing the position of the room
Returns:Whether or not that position is legal to occuply.
Return type:boolean
nonrandom_position(flavour_function)[source]

Non-randomly select doorway to use based on the flavour function.

Parameters:flavour_function (function) – A function from this class (or a custom one)
nrp_flavour_center_hole(x, y, z)[source]

A ‘flavour’ which avoids placing rooms in the center

Parameters:
  • x (int) – x position
  • y (int) – y position
  • z (int) – z position
Returns:

a float which should be applied as the probability of chosing this position

Return type:

float

nrp_flavour_plain(x, y, z)[source]

The base flavour which has no preferences

Parameters:
  • x (int) – x position
  • y (int) – y position
  • z (int) – z position
Returns:

a float which should be applied as the probability of chosing this position

Return type:

float

nrp_flavour_vertical(x, y, z)[source]

A ‘flavour’ which strongly encourages verticality

Parameters:
  • x (int) – x position
  • y (int) – y position
  • z (int) – z position
Returns:

a float which should be applied as the probability of chosing this position

Return type:

float

place_rooms(debug, possible_rooms, rooms=10)[source]
preregister_room(room)[source]

Register positions occupied by this room, but don’t actually do it, only attempt to do it in a temporary manner. Useful for validating that multi-room rooms work OK even under mirrored circumstances.

Parameters:rooms (list(redeclipse.prefabs.Room)) – An array of redeclipse.prefabs.Room that are to be pre-registered.
Returns:Whether or not it is OK to register this room.
Return type:boolean
random_position()[source]

Select a random doorway to use

Returns:a doorway from the set of unoccupied doorways.
Return type:tuple of (position, room, orientation), whatever the heck those are.
random_room(connecting_room, room_options)[source]

Pick out a random room based on the connecting room and the transition probabilities of that room.

random_room_stream(connecting_room, room_options)[source]
register_room(room)[source]

Register positions occupied by this room

Parameters:room (redeclipse.prefabs.Room) – A single room that is to be added to the world.
Return type:None
room_localization(possible_rooms, prev_room_door, prev_room, prev_room_orientation)[source]

Given a set of possible rooms, this will randomly choose a location, and emit a stream of orientations for rooms that could be attached.

classmethod weighted_choice(choices)[source]

Weighted random distribution. Given a list like [(‘a’, 1), (‘b’, 2)] will return a 33% of the time and b 66% of the time.