# Reverse engineer video game function/formula

Posted 6 months ago
1429 Views
|
6 Replies
|
0 Total Likes
|
 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 Attackersy = # of Defendersd = Damage output constant/coefficient = 0.1a = Damage absorption constant/coefficient = 0.01The 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, 100f(1200, 1000) = 89, 110f(1300, 1000) = 88, 120f(1400, 1000) = 87, 130f(1500, 1000) = 86, 140f(1600, 1000) = 86, 150f(1700, 1000) = 85, 160f(1800, 1000) = 84, 170f(1900, 1000) = 84, 180f(2000, 1000) = 83, 190f(2100, 1000) = 82, 200f(2200, 1000) = 81, 210f(2300, 1000) = 81, 220f(2400, 1000) = 80, 230f(2500, 1000) = 80, 240f(2600, 1000) = 79, 250f(2700, 1000) = 78, 260f(2800, 1000) = 78, 270Anyway, I'm stuck. Does anyone have an idea of what I could try?
6 Replies
Sort By:
Posted 6 months ago
 The data given only has y=1000 so you can't expect to find out the effect of y. You can only (potentially) determine the formula for dx as a function of x given that y=1000.But you can get some pretty strong hints as to some of the features of the function by plotting the data. ListPlot[data[[All, {1, 3}]], Frame -> True, FrameLabel -> {"x", "dx"}] The slopes of neighboring points seem to take on just two values: 0 and -0.1. Also, the intercepts change by +1 every once in a while. LinearModelFit[data[[#[[1]] ;; #[[2]], {1, 3}]], x, x]["BestFitParameters"] & /@ {{1, 5}, {6, 8}, {9, 12}, {13, 14}, {15, 17}} (* {{101., -0.01}, {102., -0.01}, {103., -0.01}, {104., -0.01}, {105., -0.01}} *) Show[ListPlot[(data[[#[[1]] ;; #[[2]], {1, 3}]] & /@ {{1, 5}, {6, 8}, {9, 12}, {13, 14}, {15, 17}}), Frame -> True, FrameLabel -> {"x", "dx"}], ListPlot[(data[[#[[1]] ;; #[[2]], {1, 3}]] & /@ {{1, 5}, {6, 8}, {9, 12}, {13, 14}, {15, 17}}), Joined -> True]]
Posted 6 months ago
 Hi Jim,I noticed the stairstep appearance, but I haven’t found a function yet which would produce the inconsistent height.I have been thinking that plotting the values along an x, y, and z axis might reveal something, but I haven’t figured out how to do that yet. It sounds like a stretch anyway.I had assumed that keeping y constant would simplify deriving how dx decreased as x increased, but it sounds like you’re saying that may obscure the solution.I’ll give that a try, in the meantime, thanks for the tip.
Posted 6 months ago
 Use ListPointPlot3D: data = {{1100, 1000, 90, 100}, {1200, 1000, 89, 110}, {1300, 1000, 88, 120}, {1400, 1000, 87, 130}, {1500, 1000, 86, 140}, {1600, 1000, 86, 150}, {1700, 1000, 85, 160}, {1800, 1000, 84, 170}, {1900, 1000, 84, 180}, {2000, 1000, 83, 190}, {2100, 1000, 82, 200}, {2200, 1000, 81, 210}, {2300, 1000, 81, 220}, {2400, 1000, 80, 230}, {2500, 1000, 80, 240}, {2600, 1000, 79, 250}, {2700, 1000, 78, 260}, {2800, 1000, 78, 270}}; ListPointPlot3D[data[[All, {1, 2, 3}]]] But with y being constant, it's not a very interesting display.And my point about needing y to vary is that IF the formula depends on y you can't get there from here if y doesn't vary. It might end up that y isn't used at all in the formula but one can't know that either without varying y.
Posted 6 months ago
 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]]