aliens

Author Topic: In-game manufacturing profitability view  (Read 56414 times)

Offline hellrazor

  • Commander
  • *****
  • Posts: 2025
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: In-game manufacturing profitability view
« Reply #15 on: March 29, 2015, 12:01:00 am »
Manufacturing items for sale is not what vanilla xcom about. Literally, it's just side effect of the "selling" feature of the game. AFAIK xcom2012 doen't have that at all. Hell, it's the game about fighting alien invasion, not getting billionaire.

Need more money to hire more personal and setup more bases. Sorry but for a big global game with a lot of bases selling Laser Canons is a must!

Offline myk002

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: In-game manufacturing profitability view
« Reply #16 on: March 29, 2015, 03:32:44 am »
Ok, so here's the next attempt.  All changes to the NewManufactureList page have been reverted.  Instead, I added two lines to the ManufactureInfo page to track remaining materials cost and net funds change per month.  These values change with the number of allocated engineers and the number of units to produce, so they are always useful, even if the player already knows which items are profitable.  The net value takes into account all the factors on the profitability wiki page and clamp appropriately if the number of items remaining to manufacture is less than the monthly capacity.  I opted to add the text lines instead of replacing the "SELL" text on the button so I could include an explanatory label (and so I could add both items instead of just one).  Also, it was difficult to read a numeric label on a toggle button since the colors get inverted when the button is in the on state. Thoughts?
« Last Edit: March 29, 2015, 04:24:13 am by myk002 »

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Re: In-game manufacturing profitability view
« Reply #17 on: March 29, 2015, 05:46:09 pm »
Looks great to me! I am a big fan of more information on the manufacturing pages.

If you want to look into more manufacturing stuff, adding the possibility to list produced items when there are more than 1 would be great, on the same screen where it lists the required items. That would be great for modded manufacture projects that produce more than one item.

Offline Jstank

  • Colonel
  • ****
  • Posts: 247
  • 100% Un-Professional XCOM Lets Player
    • View Profile
    • FINAL MOD PACK LP OUT SOON NOW RECRUITING! SIGN UP TODAY!
Re: In-game manufacturing profitability view
« Reply #18 on: March 29, 2015, 10:44:03 pm »
Oh wow I really like that much better. Is there a way to select the denominator, like per unit, per day, per hour.

It would be neat to see the economy of scale factored in and see profitability change when you incorporate how much cost a month engineers have on the overall numbers as you add or subtract engineers. Now i want to see the graphs..... This would make it not as static as one criticism put it.

Something about the last two numbers don't make sense to my feeble brain. If you use 70 engineers to produce 100 shouldnt it output the same number as using 70 engineers to produce infinite? Unless 100 took more than a month?

Also does it take into account facility cost? If there is a monthly cost for running a workshop?

Oh god I'm getting to into this someone stop me.


Jstank
« Last Edit: March 29, 2015, 10:54:15 pm by Jstank »

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Re: In-game manufacturing profitability view
« Reply #19 on: March 30, 2015, 12:54:54 am »
What mean "Remaining materials cost"?

Offline kikimoristan

  • Commander
  • *****
  • Posts: 647
    • View Profile
Re: In-game manufacturing profitability view
« Reply #20 on: March 30, 2015, 12:56:20 am »
i m into it

Offline kikimoristan

  • Commander
  • *****
  • Posts: 647
    • View Profile
Re: In-game manufacturing profitability view
« Reply #21 on: March 30, 2015, 12:57:40 am »
would be interesting to make it so you somehow let computer autobattle and you just produce items /manage troops . there are a few games like that . is all gonna be just inside the base building things and random things going in and out depending on computer success rate with missions.

Offline myk002

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: In-game manufacturing profitability view
« Reply #22 on: March 30, 2015, 02:14:49 am »
adding the possibility to list produced items when there are more than 1 would be great, on the same screen where it lists the required items.
I'll take a look at that once I get this wrapped up.

Is there a way to select the denominator, like per unit, per day, per hour.
There could be, but I fear it would clutter the UI.  The units are per month since that is how the finances in the rest of the game are measured, and is the most relevant to a player who is trying to figure out whether they will have enough money at the end of the month to cover expenses.

Quote
It would be neat to see the economy of scale factored in and see profitability change when you incorporate how much cost a month engineers have on the overall numbers as you add or subtract engineers. Now i want to see the graphs..... This would make it not as static as one criticism put it.
The numbers do change according to the number of engineers you have assigned, and you can see, for instance, the profit going from negative to positive as you cross the critical theshold for assigned engineers for the (profitable) item you are producing.

Quote
Something about the last two numbers don't make sense to my feeble brain. If you use 70 engineers to produce 100 shouldnt it output the same number as using 70 engineers to produce infinite? Unless 100 took more than a month?

Also does it take into account facility cost? If there is a monthly cost for running a workshop?
What mean "Remaining materials cost"?

The numbers would be the same if the number of units to produce were more than the number of engineers could produce in a month.  For example, if the 70 engineers were producing 1000 motion scanners, the profit number would equal the one where they are producing infinite scanners.

Here are the equations that make up the main business logic of this change:
Code: [Select]
remainingMaterialsCost = (manufactureCost + usedItemsValue) * (amountTotal - amountProduced)
manufactureCost: the number listed in the ruleset that you are charged per item produced.
usedItemsValue: the sale price of any other items required to manufacture this item (like alloys)
amountTotal: the number you specified to manufacture when you started the job
amountProduced: the number of items you've produced so far.  this will be 0 when you first create the job and non-zero when you look at a manufacturing job in progress

Code: [Select]
monthlyNetProfit = (saleValue - (manufactureCost + usedItemsValue)) * itemsPerMonth
    - (salaryCost + livingCost + workshopCost) * capacity
saleValue: the money you get from selling the item.  this is 0 if the "SELL" button is not toggled on
manufactureCost, usedItemsValue: same as above
itemsPerMonth: the number of items specified to produce in the job or the number of items the current number of assigned engineers can produce in one month, whichever is less
salaryCost: the salaries of the assigned engineers
livingCost: the maintenance cost of the living quarters for the assigned engineers
workshopCost: the maintenance cost of all the workshops
capacity: the percentage of one month this job will take.  this is 1 if the job will take one month or longer.
« Last Edit: March 30, 2015, 02:18:12 am by myk002 »

Offline myk002

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: In-game manufacturing profitability view
« Reply #23 on: March 30, 2015, 02:29:41 am »
Adding a new post since the previous post was getting a bit long.

Looking over this, I wonder whether these are the right numbers to report.  Perhaps the real questions the numbers should answer are:
1) at the end of this job, what will be the change in my net worth?
2) during this job, what will be the rate of change of my net worth?

that is, make the numbers net-worth focused, not strictly funds focused.

perhaps the equations should be:
Code: [Select]
remainingNetWorthChange = (producedItemsValue - (manufactureCost + usedItemsValue)) * (amountTotal - amountProduced)

monthlyNetWorthChange = (producedItemsValue - (manufactureCost + usedItemsValue)) * itemsPerMonth
    - (salaryCost + livingCost + workshopCost) * capacity
The main difference being the use of producedItemsValue in the two equations, which is the combined sale value of all the produced items.

What do you guys think?  What is the question *you* would like answered on this page?
« Last Edit: March 30, 2015, 02:32:48 am by myk002 »

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Re: In-game manufacturing profitability view
« Reply #24 on: March 30, 2015, 02:30:17 am »
Here are the equations that make up the main business logic of this change:
Code: [Select]
remainingMaterialsCost = (manufactureCost + usedItemsValue) * (amountTotal - amountProduced)
manufactureCost: the number listed in the ruleset that you are charged per item produced.
usedItemsValue: the sale price of any other items required to manufacture this item (like alloys)
amountTotal: the number you specified to manufacture when you started the job
amountProduced: the number of items you've produced so far.  this will be 0 when you first create the job and non-zero when you look at a manufacturing job in progress

Omg! Better to remove the "Remaining Materials Cost" from the screen.
Profit per month - it's all what need for player. :)
« Last Edit: March 30, 2015, 02:37:06 am by redv »

Offline DoxaLogos (JG)

  • Colonel
  • ****
  • Posts: 358
  • Squaddie cautiously peering through the breach
    • View Profile
Re: In-game manufacturing profitability view
« Reply #25 on: March 30, 2015, 03:23:49 am »
Agreed. I like the idea of this, but net worth relies on too many other assumptions about your finances that would have to be stable to be worthwhile.  All I care about is how much profit I would be generating.  Keep it simple and straightforward.

Offline Jstank

  • Colonel
  • ****
  • Posts: 247
  • 100% Un-Professional XCOM Lets Player
    • View Profile
    • FINAL MOD PACK LP OUT SOON NOW RECRUITING! SIGN UP TODAY!
Re: In-game manufacturing profitability view
« Reply #26 on: March 30, 2015, 04:14:19 am »
Could you add the Agragate_Net_Profit for all ongoing base finances to your bottom line on the finances screen? That way it will add your production profits to your final budget total?

Offline myk002

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: In-game manufacturing profitability view
« Reply #27 on: March 30, 2015, 05:39:38 am »
Could you add the Agragate_Net_Profit for all ongoing base finances to your bottom line on the finances screen? That way it will add your production profits to your final budget total?
that might take some discussion -- changing what one of the chart lines means will undoubtedly cause confusion, but adding a new line might not be very useful.  Anyway, let me run the next version of the manufacturing screen by everyone.

Screen reduced by 15 pixels, net worth delta line removed.   I do think that line had some value (i.e. gives a reference for the opportunity cost of manufacturing a needed item), but I can definitely see how it can cause significant confusion, especially when net worth goes up but net funds go down (like when you manufacture a valuable item but are not selling it).

Offline redv

  • Colonel
  • ****
  • Posts: 335
    • View Profile
Re: In-game manufacturing profitability view
« Reply #28 on: March 30, 2015, 01:13:36 pm »


Something wrong in formula.
Workshop - maintenance cost: $35,000/month;  50 units of space.
Motion Scanner - manufacturing price: $34,000; space required: 4.

Monthly cost: -35K * (4 / 50) - 34K = -36.8K

Offline myk002

  • Colonel
  • ****
  • Posts: 227
    • View Profile
Re: In-game manufacturing profitability view
« Reply #29 on: March 30, 2015, 02:16:21 pm »
Monthly cost: -35K * (4 / 50) - 34K = -36.8K
This brings up a good point.  In order to calculate *manufacturing* profitability (as opposed to isolated *job* profitability), I don't scale the cost of the workshop maintenance to the amount of workshop space that is used.  This is because unlike living space, which is shared among other purposes, there is no other use for workshops.  Even if we're not using some workshop space, we're still paying for it, and it affects the calculation for monthly profit.  The profitability wiki page implicitly does the same thing since it assumes all manufacturing capacity is fully utilized.  If I scaled the workshop maintenance, it would give an unrealistically positive view of how much profit you'll be making per month.

in this case, in the initial state, you're paying for the workshop maintenance (35k * 2), but producing no items (engineers = 0), leading to an initial profit of -70K.

Here's the full algorithm for review:
Spoiler:
Code: [Select]
int _totalLivingSpace, _totalLivingQuartersMaintenance, _totalWorkshopMaintenance, _producedItemsValue, _usedItemsValue;

void ManufactureInfoState::initProfitInfo ()
{
Ruleset *ruleset = _game->getRuleset();
const RuleManufacture *item = _production->getRules();

_totalLivingSpace               = 0;
_totalLivingQuartersMaintenance = 0;
_totalWorkshopMaintenance       = 0;
for (std::vector<BaseFacility *>::const_iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
if (0 != (*i)->getBuildTime())
{
https:// don't count unbuilt facilities
continue;
}

RuleBaseFacility *rbf = (*i)->getRules();
bool costAccountedFor = false;
if (rbf->getWorkshops())
{
_totalWorkshopMaintenance += rbf->getMonthlyCost();
costAccountedFor = true;
}

if (rbf->getPersonnel())
{
_totalLivingSpace += rbf->getPersonnel();
if (!costAccountedFor)
{
https:// don't count the cost twice for facilities that provide
https:// both workshops and living space
_totalLivingQuartersMaintenance += rbf->getMonthlyCost();
}
}
}

_producedItemsValue = 0;
for (std::map<std::string, int>::const_iterator i = item->getProducedItems().begin(); i != item->getProducedItems().end(); ++i)
{
int sellCost = 0;
if (item->getCategory() == "STR_CRAFT")
{
sellCost = ruleset->getCraft(i->first)->getSellCost();
}
else
{
sellCost = ruleset->getItem(i->first)->getSellCost();
}
_producedItemsValue += sellCost * i->second;
}

_usedItemsValue = 0;
for (std::map<std::string, int>::const_iterator i = item->getRequiredItems().begin(); i != item->getRequiredItems().end(); ++i)
{
_usedItemsValue += ruleset->getItem(i->first)->getSellCost() * i->second;
}
}

https:// algorithm based on profitability calculations done on
https:// https://www.ufopaedia.org/index.php?title=Manufacturing_Profitability
int ManufactureInfoState::getMonthlyNetProfit ()
{
Ruleset *ruleset = _game->getRuleset();
const RuleManufacture *item = _production->getRules();

static const int HOURS_PER_MONTH = 24 * 30;
int numEngineers = _production->getAssignedEngineers();
int manHoursPerMonth = HOURS_PER_MONTH * numEngineers;
float itemsPerMonth = (float)manHoursPerMonth / (float)item->getManufactureTime();

float percentUtilized = 1.0;
int itemsRemaining = _production->getAmountTotal() - _production->getAmountProduced();
if (!_production->getInfiniteAmount() && itemsPerMonth > itemsRemaining)
{
https:// less than one month's amount of work left; scale the costs accordingly
percentUtilized = itemsRemaining / itemsPerMonth;
itemsPerMonth = itemsRemaining;
}

int saleValue = _btnSell->getPressed() ? _producedItemsValue : 0;
int salaryCost = ruleset->getEngineerCost() * numEngineers;
int livingCost = (_totalLivingQuartersMaintenance * numEngineers) / _totalLivingSpace;

return (saleValue - (item->getManufactureCost() + _usedItemsValue)) * itemsPerMonth
- (salaryCost + livingCost + _totalWorkshopMaintenance) * percentUtilized;
}
« Last Edit: March 30, 2015, 02:27:38 pm by myk002 »