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

Missing steps for energy and total mass #90

Closed ezio-melotti closed 5 years ago

ezio-melotti commented 5 years ago

After the latest update, some steps are missing again. In particular the energy production and the total agent mass are missing steps 1, 24, 48, etc. This can be seen clearly in the Energy Levels graph on the blue line.

ezio-melotti commented 5 years ago

To clarify, I do get the steps, but some values are missing:

{
  "message": "Step data retrieved.",
  "step_data": {
    "1": {
      "user_id": 1,
      "username": "eziom",
      "start_time": 1567162677,
      "game_id": 7454981,
      "step_num": 1,
      "hours_per_step": 1,
      "is_terminated": "False",
      "time": 3600,
      "termination_reason": null,
      "total_agent_mass": {
        "wheat": {},
        "cabbage": {},
        "strawberry": {},
        "radish": {},
        "red_beet": {},
        "lettuce": {}
      },
      "total_agent_count": {
        "human_agent": 4
      },
      "total_production": {
        "atmo_co2": {
          "value": 0.2575,
          "unit": "1.0 kg"
        },
        "atmo_o2": {
          "value": 0.367,
          "unit": "1.0 kg"
        },
        "h2o_potb": {
          "value": 4.75,
          "unit": "1.0 kg"
        },
        "enrg_kwh": {}
      },
      "total_consumption": {
        "atmo_o2": {
          "value": 0.19725,
          "unit": "1.0 kg"
        },
        "h2o_potb": {
          "value": 2.064926,
          "unit": "1.0 kg"
        },
        "enrg_kwh": {
          "value": 6.861,
          "unit": "1.0 kWh"
        }
      },
      "storage_ratios": {
        "air_storage_1": {
          "atmo_co2": 0.0003757336564877036,
          "atmo_o2": 0.21000786516188438,
          "atmo_ch4": 0.0000012780444081355528,
          "atmo_n2": 0.7885656992846389,
          "atmo_h2": 0.000005069279498508086,
          "atmo_h2o": 0.0010443545730825221
        }
      }
    },
    "2": {
      "user_id": 1,
      "username": "eziom",
      "start_time": 1567162677,
      "game_id": 7454981,
      "step_num": 2,
      "hours_per_step": 1,
      "is_terminated": "False",
      "time": 7200,
      "termination_reason": null,
      "total_agent_mass": {
        "wheat": {
          "value": 5.80392e-12,
          "unit": "1.0 kg"
        },
        "cabbage": {
          "value": 6.06247e-13,
          "unit": "1.0 kg"
        },
        "strawberry": {
          "value": 2.00431e-12,
          "unit": "1.0 kg"
        },
        "radish": {
          "value": 4.80353e-12,
          "unit": "1.0 kg"
        },
        "red_beet": {
          "value": 1.73054e-12,
          "unit": "1.0 kg"
        },
        "lettuce": {
          "value": 1.43448e-12,
          "unit": "1.0 kg"
        }
      },
      "total_agent_count": {
        "human_agent": 4
      },
      "total_production": {
        "atmo_co2": {
          "value": 0.2575,
          "unit": "1.0 kg"
        },
        "atmo_o2": {
          "value": 0.36700000001609945,
          "unit": "1.0 kg"
        },
        "h2o_potb": {
          "value": 4.75,
          "unit": "1.0 kg"
        },
        "enrg_kwh": {
          "value": 0.00152082,
          "unit": "1.0 kWh"
        }
      },
      "total_consumption": {
        "atmo_o2": {
          "value": 0.19725,
          "unit": "1.0 kg"
        },
        "h2o_potb": {
          "value": 2.0649260000719654,
          "unit": "1.0 kg"
        },
        "enrg_kwh": {
          "value": 6.861712848299999,
          "unit": "1.0 kWh"
        }
      },
      "storage_ratios": {
        "air_storage_1": {
          "atmo_co2": 0.0004014455990631124,
          "atmo_o2": 0.21000554160304297,
          "atmo_ch4": 0.0000016028827891857421,
          "atmo_n2": 0.7884931492432639,
          "atmo_h2": 0.000009608197968112025,
          "atmo_h2o": 0.001088652473872769
        }
      }
    },
  }
}

As you can see here in the first step the total_agent_mass and enrg_kwh under total_production are empty, whereas in the second step they are ok.

ezio-melotti commented 5 years ago

To clarify further, the total_agent_mass is only missing in the first step, whereas enrg_kwh is missing every 24 steps. The easy fix is to replace the empty dict with something like {'value': 0} in https://github.com/kstaats/simoc/blob/b690f6ca0e9e1b31a961e34781909b2624462f89/simoc_server/front_end_routes.py#L344-L346 The unit should probably be included too, but currently I don't think I use it.

ezio-melotti commented 5 years ago

@Pebody fixed this in cf5715adbf8c07e5579dc9d87e0029ba436842c8