# Which algorithm can I use to minimise the number of wins of 2 weapons that fight each other in a game?

I have a game that involves 2 weapons, which fight against each other. Each weapon has 5 features/statistics, which have certain range. I can simulate the game $$N$$ times with randomly initialised values for these statitics, in order to collect a dataset. I can also count the number of times a weapon wins, loses or draws against the other.

I'm looking for an algorithm that minimises the number of wins of the 2 weapons (maybe by changing these features), so that they are balanced.

• Comments are not for extended discussion; this conversation has been moved to chat.
– nbro
Nov 7, 2021 at 18:29

I'm going to start by trying to restate your problem as I understand it.

1. You have a game which contains weapons.
2. Weapons are characterized by 5 different numbers, which can range over different values (1-5 in your examples?).
3. You have a way to simulate combat involving the two weapons.
4. The combat is random, but can be repeated many times. An average win rate can be determined.
5. 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 <- 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.