How can I assemble an equation from these guide points?

39 Views Asked by At

For context, I am programming a building system and I want to encourage players to build with larger blocks for a given volume of world space and discourage occupying the same space, but with multiple, smaller blocks. To do this, I would like to create a function that makes larger blocks cost less per unit to create compared to smaller blocks. The block sizes are determined entirely by the player, so I cannot statically hardcode specific values for every unique size.

Now, I have a rough idea of how much certain block sizes should cost to complete, but there are two main problems I have encountered:

  1. I do not know how to get the cost for sizes in between the sizes in the table below.
  2. I do not know how to properly create an equation for the table below.

This is the table used to roughly determine the volume of material needed to "fill" or "complete" a given block/blueprint.

Blueprint Volume (x) Fill Units (material cost) (y) Volume-to-Fill Ratio (r)
1x1x1 Cube 1 1 1
2x2x2 Cube 8 4 0.5
4x4x4 Cube 64 16 0.25
8x8x8 Cube 512 64 0.125
16x16x16 Cube 4096 256 0.0625
32x32x32 Cube 32768 1024 0.03125
64x64x64 Cube 262144 4096 0.015625

Now, how can I get an equation that given the volume of the blueprint (let's call it x) returns this discounted material cost/fill units (let's call it y). The Volume-to-Fill Ratio is there to help constructing an equation. It is the rate of change or let's call it r.

It is my understanding that this should roughly be an equation like $y=x*r$ or something similar to that. However, how do I find r, given just the blueprint volume (x)?

Alternatively, if there is a better way to structure the equation, that would be welcome too.

Thanks in advance.

1

There are 1 best solutions below

1
On BEST ANSWER

For question 2, your table has $y=\sqrt[3]{x^2}$ and $r=\frac{1}{\sqrt[3]{x}}$.

For question 1, I think you can just use the same equation as above. If it has to be an integer value, you can use the floor function as well.