overthesun / simoc

A scalable model of an interactive, off-world community
https://ngs.simoc.space/
GNU General Public License v3.0
2 stars 2 forks source link

Calculate and send storage capacities from /new_game #122

Open ezio-melotti opened 3 years ago

ezio-melotti commented 3 years ago

In 918bcd8 I updated the /new_game route to send back the full game_config, which includes info about the storages. However the total capacities of the storages are not included. For example the power_storage only includes {'enrg_kwh': 1000} and there is no way to know if we have a 5000 kWh battery that is 20% full or a completely full 1000 kWh battery.

For the storages there are different capacities, for example the air_storage defines the capacity for each of the currencies/elements, and the total volume in the agent_desc.json file:

https://github.com/overthesun/simoc/blob/f136cc22296616a2477afc41f0232f8281bb2603/agent_desc.json#L6163-L6211

This piece of code seems to retrieve the capacity for each element: https://github.com/overthesun/simoc/blob/f136cc22296616a2477afc41f0232f8281bb2603/simoc_server/front_end_routes.py#L250-L251

But this other piece of code: https://github.com/overthesun/simoc/blob/f136cc22296616a2477afc41f0232f8281bb2603/simoc_server/front_end_routes.py#L149-L168 Uses the total volume of the greenhouse/habitat to calculate the capacity of the storage.

Since the volume is in square meters, in https://github.com/overthesun/simoc/blob/f136cc22296616a2477afc41f0232f8281bb2603/simoc_server/front_end_routes.py#L94-L114

the volume gets converted into kg, which is the same unit used to track the amount of elements in the air_storage. This value however is not stored/used anywhere else, and it's what I need.

As an example, a 1 human preset sim, uses small crew quarters and no greenhouse. The volume of the small crew quarters is 1000 square meters, so the air storage (i.e. the air inside the crew quarters) is 1250 kg (which is what I need). This value contradicts the default air storage volume (3.568 m^3) and mass (4348.5 kg) and also the combined capacity of each of the elements in the air_storage (42000 kg).

For the water storage the values in kg and square meters coincide (i.e. a 1000 m^3 crew quarter will have a water storage of 1000 m^3 / 1000 kg), so there's nothing to do. For the power storage the volume is present in the agent_desc.json but ignored (and this is inconsistent, since the volume is sometimes used to indicate how much space is available inside the storage and other times the total space the storage takes), and the capacity of the enrg_kwh coincides with the total capacity. In addition the max capacity can also be passed by the client (I assume it overrides the value in the agent_desc.json).

So to summarize:

This raises a few questions:

  1. do the volume/mass in the agent_desc.json refer to the storage itself or to the content of the storage?
  2. if they refer to the storage itself, should we add an internal_capacity?
  3. or should the internal capacity be calculated by adding together the max capacities of the currencies it contains?
  4. if done this way, how can we passed a new total storage capacity from the configuration wizard?
  5. does it make sense to have separate capacities for each element in the air storage, since they are all mixed?
  6. should the separate capacities be expressed as a percentage of the total instead?
  7. or should we have individual storages for currencies that should not be mixed and a "storage group" to group them together?
  8. what would be a good way to handle all this in a generic way?

This is what I think we should do:

ezio-melotti commented 3 years ago

In #123 I added the capacities of the air and water storages, and sent those back to the frontend.