Esempio n. 1
0
 def __init__(self, configuration):
     """Initialise the renderer"""
     self.addLogger()
     self.configuration = configuration
     self.name = common.getStrAttr(configuration, 'name')
     self.confirmation_message = common.getStrAttr(configuration, 'confirmationMessage', '')
     self.log.debug('Renderer created')
 def __init__(self, configuration):
     """Initialise the renderer"""
     self.addLogger()
     self.configuration = configuration
     self.name = common.getStrAttr(configuration, 'name')
     self.confirmation_message = common.getStrAttr(configuration, 'confirmationMessage', '')
     self.log.debug('Renderer created')
Esempio n. 3
0
 def __init__(self, configuration):
     """Initialise the builder"""
     super(EvolutionBased, self).__init__(configuration)
     #
     # Find the rooms
     self.rooms = {}
     for room_configuration in configuration.find('rooms').findall('room'):
         room = Room(
             common.getStrAttr(room_configuration, 'name'),
             common.getStrAttr(room_configuration, 'type'),
             [line.strip() for line in room_configuration.text.strip().splitlines()]
         )
         self.rooms[room.name] = room
     #
     # Get properties
     self.initial_pool_size = common.getInt(configuration, 'initialPoolSize')
     self.tournament_size = common.getInt(configuration, 'tournamentSize')
     self.max_iterations = common.getInt(configuration, 'maxIterations')
     #
     # Tuning parameters
     RoomController.target_num_rooms = common.getFloat(configuration, 'targetRooms')
     RoomController.missed_corridor_penalty = common.getFloat(configuration, 'missedCorridorPenalty')
     RoomController.corridor_to_room_penalty = common.getFloat(configuration, 'corridorToRoomPenalty')
     RoomController.exit_longest_path_multiplier = common.getFloat(configuration, 'exitLongestPath')
     RoomController.missed_door_penalty = common.getFloat(configuration, 'missedDoorPenalty')
     #
     RoomController.target_room_types['event'] = common.getFloat(configuration, 'numEventRooms')
     RoomController.target_room_types['treasure'] = common.getFloat(configuration, 'numTreasureRooms')
     RoomController.target_room_types['corridor'] = common.getFloat(configuration, 'numCorridors')
 def __init__(self, configuration):
     """Initialise the builder"""
     super(EvolutionBased, self).__init__(configuration)
     #
     # Find the rooms
     self.rooms = {}
     for room_configuration in configuration.find("rooms").findall("room"):
         room = Room(
             common.getStrAttr(room_configuration, "name"),
             common.getStrAttr(room_configuration, "type"),
             [line.strip() for line in room_configuration.text.strip().splitlines()],
         )
         self.rooms[room.name] = room
     #
     # Get properties
     self.initial_pool_size = common.getInt(configuration, "initialPoolSize")
     self.tournament_size = common.getInt(configuration, "tournamentSize")
     self.max_iterations = common.getInt(configuration, "maxIterations")
     #
     # Tuning parameters
     RoomController.target_num_rooms = common.getFloat(configuration, "targetRooms")
     RoomController.missed_corridor_penalty = common.getFloat(configuration, "missedCorridorPenalty")
     RoomController.corridor_to_room_penalty = common.getFloat(configuration, "corridorToRoomPenalty")
     RoomController.exit_longest_path_multiplier = common.getFloat(configuration, "exitLongestPath")
     RoomController.missed_door_penalty = common.getFloat(configuration, "missedDoorPenalty")
     #
     RoomController.target_room_types["event"] = common.getFloat(configuration, "numEventRooms")
     RoomController.target_room_types["treasure"] = common.getFloat(configuration, "numTreasureRooms")
     RoomController.target_room_types["corridor"] = common.getFloat(configuration, "numCorridors")
Esempio n. 5
0
 def __init__(self, configuration):
     """Initialise the builder"""
     super(PortCreator, self).__init__(configuration)
     #
     # Basic properties of the port
     self.coast_per_port = common.getInt(configuration,
                                         'averageCoastLinePerPort')
     self.island_must_have_port = common.getTrue(configuration,
                                                 'islandMustHavePort')
     self.min_port_separation = common.getInt(configuration,
                                              'minimumPortSeparation')
     self.port_location_attempts = common.getInt(configuration,
                                                 'portLocationAttempts', 5)
     self.max_name_length = common.getInt(configuration,
                                          'maxPortNameLength', 9)
     #
     # Resource properties
     properties = configuration.findall('resources/resourceProperties/*')
     root = configuration.find('resources/resourceProperties')
     self.property_ranges = dict(
         (element.tag, common.getFloatTuple(root, element.tag))
         for element in properties)
     #
     self.name_generator = serge.blocks.textgenerator.MarkovNameGenerator(
         serge.blocks.textgenerator.EUROPE)
     #
     # Resource types
     self.resource_types = [
         common.getStrAttr(element, 'name') for element in
         configuration.findall('resources/resourceTypes/resource')
     ]
 def __init__(self, configuration):
     """Initialise the builder"""
     super(PortCreator, self).__init__(configuration)
     #
     # Basic properties of the port
     self.coast_per_port = common.getInt(configuration, 'averageCoastLinePerPort')
     self.island_must_have_port = common.getTrue(configuration, 'islandMustHavePort')
     self.min_port_separation = common.getInt(configuration, 'minimumPortSeparation')
     self.port_location_attempts = common.getInt(configuration, 'portLocationAttempts', 5)
     self.max_name_length = common.getInt(configuration, 'maxPortNameLength', 9)
     #
     # Resource properties
     properties = configuration.findall('resources/resourceProperties/*')
     root = configuration.find('resources/resourceProperties')
     self.property_ranges = dict(
         (element.tag, common.getFloatTuple(root, element.tag)) for element in properties
     )
     #
     self.name_generator = serge.blocks.textgenerator.MarkovNameGenerator(
         serge.blocks.textgenerator.EUROPE
     )
     #
     # Resource types
     self.resource_types = [
         common.getStrAttr(element, 'name')
         for element in configuration.findall('resources/resourceTypes/resource')
     ]
Esempio n. 7
0
 def __init__(self, configuration):
     """Initialise the renderer"""
     super(StringRenderer, self).__init__(configuration)
     #
     self.default_value = common.getString(configuration, 'defaultValue')
     self.values = {}
     for value in configuration.find('attributeValues').findall('attributeValue'):
         self.values[common.getStrAttr(value, 'tag')] = common.getTupleAttr(value, 'colour')
Esempio n. 8
0
 def __init__(self, configuration):
     """Initialise the builder"""
     super(BiomeTagger, self).__init__(configuration)
     #
     self.ranges = []
     for biome_range in configuration.find('heightRanges').findall('range'):
         self.ranges.append((common.getIntAttr(biome_range, 'low'),
                             common.getIntAttr(biome_range, 'high'),
                             common.getStrAttr(biome_range, 'tag')))
 def __init__(self, configuration):
     """Initialise the builder"""
     self.addLogger()
     self.configuration = configuration
     self.name = common.getStrAttr(configuration, 'name')
     self.log.debug('Builder created')
     #
     self._progress_percent = 0
     self._progress_world = None
     self._should_stop = False
Esempio n. 10
0
 def __init__(self, configuration):
     """Initialise the builder"""
     self.addLogger()
     self.configuration = configuration
     self.name = common.getStrAttr(configuration, 'name')
     self.log.debug('Builder created')
     #
     self._progress_percent = 0
     self._progress_world = None
     self._should_stop = False
Esempio n. 11
0
 def __init__(self, configuration):
     """Initialise the builder"""
     super(BiomeTagger, self).__init__(configuration)
     #
     self.ranges = []
     for biome_range in configuration.find('heightRanges').findall('range'):
         self.ranges.append((
             common.getIntAttr(biome_range, 'low'),
             common.getIntAttr(biome_range, 'high'),
             common.getStrAttr(biome_range, 'tag')
         ))
Esempio n. 12
0
 def __init__(self, configuration):
     """Initialise the renderer"""
     super(StringRenderer, self).__init__(configuration)
     #
     self.default_value = common.getString(configuration, 'defaultValue')
     self.values = {}
     for index, value in enumerate(configuration.find('attributeValues').findall('attributeValue')):
         self.values[common.getStrAttr(value, 'tag')] = ColourEntry(
             common.getTupleAttr(value, 'colour'),
             common.getIntAttr(value, 'index', index + 1)
         )