Skip to content

Commit

Permalink
Merge pull request #1266 from Holomanga/1168_only_add_atp_for_organel…
Browse files Browse the repository at this point in the history
…les_that_make_it

Check if organelle performs process before adding ATP production from…
  • Loading branch information
hhyyrylainen authored May 16, 2020
2 parents 89e4e2f + c28288f commit 652dc75
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/microbe_stage/ProcessSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Godot;

Expand Down Expand Up @@ -57,15 +58,25 @@ public static EnergyBalanceInfo ComputeEnergyBalance(IEnumerable<OrganelleDefini

var atp = SimulationParameters.Instance.GetCompound("atp");

foreach (var organelle in organelles)
var enumerated = organelles.ToList();

// Compute all process efficiencies once
var efficiencies = ComputeOrganelleProcessEfficiencies(enumerated, biome);

foreach (var organelle in enumerated)
{
foreach (var efficiencyInfo in
ComputeOrganelleProcessEfficiencies(organelles, biome))
foreach (var efficiencyInfo in efficiencies)
{
foreach (var processData in efficiencyInfo.Value.Processes)
{
// Find process inputs and outputs that use/produce ATP and add to
// totals
// Find process inputs and outputs that use/produce ATP
// and that are performed by this organelle
// and add to totals
if (!organelle.Processes.ContainsKey(processData.Process.InternalName))
{
continue;
}

if (processData.OtherInputs.ContainsKey(atp.InternalName))
{
var amount = processData.OtherInputs[atp.InternalName].Amount;
Expand Down

0 comments on commit 652dc75

Please sign in to comment.