My code
for each role define parts percent in the body and cost. totalPercent is the max amount of a room energy it will use parts: { pieces:[ {typeName:WORK, percent:0.5, cost:100}, {typeName:CARRY, percent:0.25, cost:50}, {typeName:MOVE, percent:0.25, cost:50} ], totalPercent:0.67 },
then you just have to go through parts.pieces the amount of each part is percent * energyRoom * totalpercent /cost
And then loop pushing each typeName in an array