It should be possible to define custom agents (including plants), by adding their definition to the game_config, at the top level. The convert_configuration() function will extract certain items from the game_config, and assume that all the remaining top-level items are agents, copying them in full_game_config['agents']:
Lines 296-297 extract the species and amount, and line 301 copies the plant agent to the top level. With this approach:
If a custom plant is defined at the top level of the game_config (aka working_config), line 301 will overwrite its definition leaving only the name and amount;
if a custom plant is defined in game_config['plants'] all the additional information (flows, properties, capacity, etc.) will be ignored, since the code only reads species and amount
While testing, we were able to work around the issue by implementing the following changes to preserve the additional information:
@@ -294,11 +294,11 @@ def convert_configuration(game_config, agent_desc=None, save_output=False):
plants = working_config.pop('plants')
for plant in plants:
amount = plant.get('amount', 0) or 0
- plant_type = plant.get('species', None)
+ plant_type = plant.pop('species')
if not (plant_type and amount):
continue
plants_in_config.append(plant_type)
- working_config[plant_type] = dict(amount=amount)
+ working_config[plant_type] = plant
if is_b2:
working_config[plant_type]['properties'] = {
'crop_management_factor': {'value': crop_mgmt_factor},
(the is_b2 case also needs to be handled, since it overrides the properties)
Later in the code flows were getting overridden too, so we tried to update the lamp by hardcoding a workaround, but it doesn't seem to work (and it should be fixed properly anyway):
Unless we are missing something, custom plant agents don't seem to currently be supported. If this is true, a proper fix that adds custom plants support by doing something similar to the workarounds pasted above should be implemented. @granawkins, can you confirm that this is necessary and that the approach we followed (passing the custom plant in game_config['plants']) makes sense?
It should be possible to define custom agents (including plants), by adding their definition to the
game_config
, at the top level. Theconvert_configuration()
function will extract certain items from thegame_config
, and assume that all the remaining top-level items are agents, copying them infull_game_config['agents']
:https://github.com/overthesun/simoc/blob/098696a40389eb72284c9e4c164fe5a39478d33c/simoc_server/front_end_routes.py#L450-L451
Plants however are handled differently:
https://github.com/overthesun/simoc/blob/098696a40389eb72284c9e4c164fe5a39478d33c/simoc_server/front_end_routes.py#L293-L306
Lines 296-297 extract the species and amount, and line 301 copies the plant agent to the top level. With this approach:
game_config
(akaworking_config
), line 301 will overwrite its definition leaving only the name and amount;game_config['plants']
all the additional information (flows, properties, capacity, etc.) will be ignored, since the code only readsspecies
andamount
While testing, we were able to work around the issue by implementing the following changes to preserve the additional information:
(the
is_b2
case also needs to be handled, since it overrides theproperties
)Later in the code
flows
were getting overridden too, so we tried to update the lamp by hardcoding a workaround, but it doesn't seem to work (and it should be fixed properly anyway):Unless we are missing something, custom plant agents don't seem to currently be supported. If this is true, a proper fix that adds custom plants support by doing something similar to the workarounds pasted above should be implemented. @granawkins, can you confirm that this is necessary and that the approach we followed (passing the custom plant in
game_config['plants']
) makes sense?