Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug commodities tab #5861

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

impaktor
Copy link
Member

@impaktor impaktor commented Jul 11, 2024

  • Fix standard deviation lacking a sqrt
  • Add filtering on purchasable goods on/off (sadly we can't buy the fuzzy little Quibbles on the commodity market)
  • Add some collapsing headers UI stuff when selected a commodity, for bling bling
  • Added some info on commodity at current station (if docked). I used this for Fix demand at News Events not being used #5859, and might need it again. It's not über-pretty, but oh, well ¯\_(ツ)_/¯

Collapsed

2024-07-11-163357_1536x960_scrot

Expanded

2024-07-11-163416_1536x960_scrot

Include non-purchasable

2024-07-11-163555_1536x960_scrot

Some info of station levels

2024-07-11-163903_1536x960_scrot

end


local function station_economy(commodities, clicked, station)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Web-eWorks If you intend to review this PR, then this function is the one where I'm half stumbling around trying to understand the economy system.

Basically, what info is meaningful to display, are the ones I have correctly named?

For completeness, I'll add this uncommitted comment I have on my local copy, adapted from IRC conversation the other day:

	-- GetCommodityStockFromFlow() returns "equilibrium" stock/demand,
	-- and price of the commodity is stored as a "pricemod", a
	-- percent-of-100 offset to the commodity's base price to compute
	-- market price for e.g. oxygen (substitute any commodity ID),
	-- you'd call
	--
	--    Economy.UpdateCommodityPriceMod(sBody, "oxygen", { stock, demand, pricemod }),
	--
	-- which stores the new pricemod in the table passed as the 3rd argument.
	-- You can then call
	--
	--    Economy.GetMarketPrice(commodity.price, pricemod)
	--
	-- to get the credit cost of the commodity

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good. Some of this information could be sourced from the commodity market datastore directly (station:GetCommodityMarket()) rather than through GetCommodityStock() et. al., though the only time that matters is in the case of a custom commodity price being set by a mission module.

Another thing to look at would potentially be to inspect the persistent market cache (stationMarket in Economy.lua), though you'd need an accessor to retrive the variable outside of the Economy module.

If you wanted to get fancier, you could provide a button that simulates the effect of restocking ticks on the commodity market - possibly make a copy of the market datastore returned from GetCommodityMarket() and call:

Economy.UpdateStationCommodityMarket(sBody, Engine.rand, marketCopy, comm.id_name, ticksToSimulate)

You could then display some sort of graph showing the commodity stock/demand levels over the simulate time - that could be a very useful tool when doing further work on the economy simulation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for suggestions. As my main driving motivation to work on this was when fixing #5859, I'll "call it a day" as for features, but keep your suggestions in mind for next time I'll want to dive into commodity balance.

data/modules/Debug/DebugCommodityPrices.lua Outdated Show resolved Hide resolved
data/modules/Debug/DebugCommodityPrices.lua Outdated Show resolved Hide resolved
data/modules/Debug/DebugCommodityPrices.lua Outdated Show resolved Hide resolved
end


local function station_economy(commodities, clicked, station)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good. Some of this information could be sourced from the commodity market datastore directly (station:GetCommodityMarket()) rather than through GetCommodityStock() et. al., though the only time that matters is in the case of a custom commodity price being set by a mission module.

Another thing to look at would potentially be to inspect the persistent market cache (stationMarket in Economy.lua), though you'd need an accessor to retrive the variable outside of the Economy module.

If you wanted to get fancier, you could provide a button that simulates the effect of restocking ticks on the commodity market - possibly make a copy of the market datastore returned from GetCommodityMarket() and call:

Economy.UpdateStationCommodityMarket(sBody, Engine.rand, marketCopy, comm.id_name, ticksToSimulate)

You could then display some sort of graph showing the commodity stock/demand levels over the simulate time - that could be a very useful tool when doing further work on the economy simulation.

- Add ui.collapsingHeader for displaying min/max/diff info
- Add stats for commodity at current station
- Don't show irrelevant stats when not purchasable
- Rename tab to something shorter

Note: if filtering out illegal goods there can still be e.g. nerve gas, if
legal at some station (but of likely fewer samples).
@Web-eWorks
Copy link
Member

Pushed a minor fix for layout and typographical issues.

@Web-eWorks Web-eWorks merged commit 8a84b93 into pioneerspacesim:master Jul 18, 2024
@impaktor impaktor deleted the fix-debug-commodities-tab branch July 18, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants