0

I am working on reverse engineering a game and have come across the following formula as a string in a config file:

A*(B^xt)+C; xt=A2*x*(T>x)*(B2^x+C2)

It would appear that I would solve for xt then plug it into the first function. However I don't know how to interpret the (T>x). I have static values for A, B, C, A2, B2, C2, T and they are as follows:

A: 300
B: 1.51
C: -319

A2: 1.8
B2: 0.93
C2: -0.64

T: 14

I know the outcomes of this equation to be:

x = 2, y = 365
x = 3, y = 714
x = 4, y = 1,241
x = 5, y = 2,036
(I can post more if needed)

My attempts to plug in the constants and x value (completely ignoring the (T>x)) have resulted in values that are not even close to what they are supposed to be. I'm hoping someone here can make sense of it, especially the (T>x) part. Thank you for any help you may be able to provide.

JoshStrange
  • 103
  • 2
  • Is the game written in a language for which booleans can be evaluated as integers, so (T>x) might be 1 (or 0) when T is greater than x, and 0 (or 1) when T is less than or equal to x? – shoover May 06 '14 at 00:13
  • T>x in some languages evaluates to 1 if true and 0 if false, but that doesn't follow with your assertion. Have you tried posting on http://www.stackoverflow.com? – mjsqu May 06 '14 at 00:15
  • @OP, are you sure that xt is evaluated by the second formula, then plugged into the first one? This is a strange order of operations. – vadim123 May 06 '14 at 00:18
  • How do you know the outcomes ? –  May 06 '14 at 00:25

2 Answers2

4

The values you've shown are consistent with y=A*(B^x)+C, if we interpret the caret ^ as exponentiation and round to the nearest integer:

300*(1.51^2)-319 =  365.03
300*(1.51^3)-319 =  713.885
300*(1.51^4)-319 = 1240.657
300*(1.51^5)-319 = 2036.082

So I'm not convinced that this code first computes xt and then plugs it into the first part; I'd suppose that the first part is computed first, using a previously established value of xt where it happens to be equal to x, and then, perhaps, the second part is used to change the value of xt to something mysterious.

  • If this is the case, then whoever specced out the config file needs a good ritual flailing. – Emily May 06 '14 at 00:20
  • I feel so incredibly stupid. I don't know why I never just tried to sub x for xt. I checked and the values match all the way up to x=14 (which is the highest x value I have a y for). Thank you very much! – JoshStrange May 06 '14 at 00:25
  • No problem. (I didn't think to plug x in for xt either; I just thought I'd try to figure out from the y values what values of xt were being used in the first expression — guessing that ^ was exponentiation, that called for computing log_B((y-C)/A), and those numbers were 2 3 4 5, so... yeah.) –  May 06 '14 at 00:28
0

The code (T > x) is used in some languages (e.g. MATLAB) as a boolean function, returning 1 when the condition is true, and 0 otherwise.

In other words, > is treated as a binary operator mapping $X\times Y$ to $\{0,1\}$.

For instance, if I had T = 4 and x = [0 1 2 3 4 5], then T > x would return [1 1 1 1 0].

Emily
  • 35,688
  • 6
  • 93
  • 141
  • $x$ is a scalar, and 2. your interpretation would suggest that "ignoring" $(T>x)$ would be equivalent to multiplying by $1$, which should lead to the right answer; but it doesn't.
  • – vadim123 May 06 '14 at 00:15
  • If x is a scalar, it makes no difference. T > x would just return 1 or 0. – Emily May 06 '14 at 00:16