0

I'm working on building a 'result table' for an RPG. In said table, you compare an effect rating to a resistance rating, to find a whole number result.

Essentially, for each cell I need to find Z, where:

  1. Z is some proportion of the difference between X and Y
  2. Z is at least one even if X=Y
  3. Z never exceeds X
  4. Z is never =X unless Y=0

For the purposes of result, cases where X<=Y are not important (as they will be considered null results), and the complexity of the formula is not an issue as it will not be used in play, though it would be ideal if it can easily put into terms of a Google Sheets formula.

I've tried a few simple ones myself from another similar design, but all seem to fail at #2 or #3. I suspect the original design may simply have been hand-tuned, but a consistent formula would be nice.

Willie Wong
  • 73,139
  • 1
    Your "axioms" are contradictory. Any number proportional to the difference between $X$ and $Y$ will be equal to zero if $X=Y$. Can you elaborate? – 5xum May 27 '14 at 07:31
  • Well, I'm open to the possibility that this is impossible, because I sure can't figure out how to do it.

    Basically, in the original design, It sooorta follows a simple Z=X-Y, except there's an additional factor involved where when X=Y, Z is still >=1. One napkin math attempt to deconstruct it into a formula gave z= x-y + x/6, but this naturally breaks #3 above. I think maybe they just handtuned the table.

    – AnnArcana May 27 '14 at 07:42
  • Well, it is impossible in the way you wrote it. Any function that is proportional to the difference between $x$ and $y$ is written as $f(x,y)=k\cdot (x-y)$ for some constant $k$. That means that for $x=y$, you have $x-y=0$ and $f(x,y)=k\cdot 0=0.$ – 5xum May 27 '14 at 07:44
  • I suspected as much. In the end I accomplished it with a conditional with a special case rule for X=Y, essentially: if X=Y then Z=X/4 else Z=X-Y + (X/4). Seems to do the trick nicely. – AnnArcana May 27 '14 at 11:51
  • For that, you do not need a special case, just write $X-Y+X/4$, this equals $X/4$ in the case of $X=Y.$ – 5xum May 27 '14 at 11:52
  • Hi, I wonder if your question is not a better fit for gamedev.SE. If you feel that is indeed the case, please leave a comment and one of the moderators will move the question over for you. – Willie Wong May 27 '14 at 15:20
  • Your formula fails for large $X$. Take $X=100,Y=1$, then $Z=124 \gt X$ The problem is that you have $Z$ growing as $\frac 54X$. You could do $Z=\frac 34(X-Y)+\frac X4$ – Ross Millikan May 27 '14 at 15:23
  • Could it just be $X-Y+1$? Not exactly proportional, but sort of. – Jack M May 27 '14 at 15:23

0 Answers0