Message Boards Message Boards

Reverse engineer video game function/formula

Posted 3 years ago

I am attempting to use Wolfram to reverse engineer a formula. Unfortunately, my background in advanced math is limited, so I've been struggling to identify which functions (or even area of mathematics) to try. Hopefully someone has a suggestion on how I could try to either recreate the formula or what sort of function would approximate a solution with the smallest degree of error.

The problem is reverse engineering combat math of a video game, specifically the result of a battle involving two forces, where the formulas calculate the number of losses from the attacker and defender. The formula for the losses of the defender is linear and simple, the losses for the attacker however are nonlinear. Given inputs:

x = # of Attackers

y = # of Defenders

d = Damage output constant/coefficient = 0.1

a = Damage absorption constant/coefficient = 0.01

The formula to determine dy (the losses of the defenders) is:

f(x * d - y * a) = (# of attackers * damage coefficient - # of defenders * damage absorption)

Given the simplicity of the function to determine the losses of the defenders, it makes sense that the function for the loss of attackers is also simple, but it has me baffled. I've been playing with Wolfram trying to identify functions to try but I'm new to the tool, and like I said, don't have a strong math background.

Some examples of the outcomes for the loss of x (attackers) and y (defenders) are:

x,    y,   = dx, dy

f(1100, 1000) = 90, 100

f(1200, 1000) = 89, 110

f(1300, 1000) = 88, 120

f(1400, 1000) = 87, 130

f(1500, 1000) = 86, 140

f(1600, 1000) = 86, 150

f(1700, 1000) = 85, 160

f(1800, 1000) = 84, 170

f(1900, 1000) = 84, 180

f(2000, 1000) = 83, 190

f(2100, 1000) = 82, 200

f(2200, 1000) = 81, 210

f(2300, 1000) = 81, 220

f(2400, 1000) = 80, 230

f(2500, 1000) = 80, 240

f(2600, 1000) = 79, 250

f(2700, 1000) = 78, 260

f(2800, 1000) = 78, 270

Anyway, I'm stuck. Does anyone have an idea of what I could try?

POSTED BY: Paul Loht
6 Replies
Posted 3 years ago

I was reading about a nonlinear staircase the other day that looked promising, but I haven’t been able to bend it to my will. I played with changing the exponent but couldn’t get there.

POSTED BY: Paul Loht
Posted 3 years ago

That's close but it doesn't work for all 18 sample points.

Show[Plot[{91 - n + Floor[(n - 1)/4]}, {n, 1, 18}], ListPlot[data[[All, 3]]]]

Prediction of dx

POSTED BY: Jim Baldwin

How about this:

data = {90, 89, 88, 87, 86, 86, 85, 84, 84, 83, 82, 81, 81, 80, 80, 79, 78, 78};

Show[
 Plot[{91 - n + Floor[(n - 1)/4]}, {n, 1, 10}],
 ListPlot[data]]

enter image description here

POSTED BY: Gustavo Delfino
Posted 3 years ago
POSTED BY: Paul Loht
Posted 3 years ago
POSTED BY: Jim Baldwin
Posted 3 years ago
POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract