Algorithm For Making Balanced Weapons In A Game? I am trying to make balanced weapon pairs. So there are five stats per weapon, and I am simulating a number of combats (1000) with different stats randomized, and counting the win, lose, and draw of the "weapon fight" for the database. I want an algorithm for making weapon1win-weapon2win as small as possible for balance through changing the weapon stats.

What happens:

Random Stats --> Combat 1000 Times --> Count Win &amp; Lose --> Data For Training The AI

Data Sample:

{[(1,2,3,4,5) --> Weapon1Stats,(5,4,3,2,1) -->Weapon2Stats,1 --> WinWeapon1-WinWeapon2],[....]} (The text isn't part of the data sample, they are just there to help you know which variable is which. Also, the {[( s are all supposed to be [ s but changed for clarity)

I would like an function, preferably in C++ or Python, but just with text that is well explained is fine, for handling the data. The result would be a method to determine how to minimize WinWeapon1-WInWeapon2.

(edit)
I would say that the one I was looking for is one with something like a score for the weapon as in strength (1*stat1 + 2*stat2 etc...) but I do want something new that works better, I am also having problems creating leeway for the functions coefficients.(edit end)
I'm going to start by trying to restate your problem as I understand it.


You have a game which contains weapons.
Weapons are characterized by 5 different numbers, which can range over different values (1-5 in your examples?).
You have a way to simulate combat involving the two weapons. 
The combat is random, but can be repeated many times. An average win rate can be determined.
You are looking for an AI algorithm that would take in a lot of pairs of statistics, along with the average win rates for one over the other, and give you insight into how to make the average win rate as close to 50% as possible.


If this sounds right, then fundamentally your problem is a form of regression, which something you could use AI for, but probably don't need to. However, your problem is probably not linear, so you need the interactions between the features. Here's what I suggest:

For each pair of weapons, store a comma separated list consisting of the stats for each weapon (one by one), followed by wins1 - wins2. At the top, list out the names of each attribute, separated by commas, (e.g. weapon1Str, weapon1Range, ... ,weapon1-weapon2 Then use a language like R that has simple support for complex forms of regression.

In R, this is then as simple as:

data &lt;- read.csv(file="Myfile.csv")
lm(formula = dist ~ .*., data = data)


This should produce a list of "coefficients", one for each of the attributes, and one for the interaction between each pair of attributes, which form a lengthy quadratic equation in 10 variables.

Any zero of that equation should be a pair of weapons that minimizes this difference.

That's probably the place to start. If it doesn't work out, maybe come post a different question and we can help more.