Answers.Body: <p>I'm going to start by trying to restate your problem as I understand it.</p>
  
  <ol>
  <li>You have a game which contains weapons.</li>
  <li>Weapons are characterized by 5 different numbers, which can range over different values (1-5 in your examples?).</li>
  <li>You have a way to simulate combat involving the two weapons. </li>
  <li>The combat is random, but can be repeated many times. An average win rate can be determined.</li>
  <li>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.</li>
  </ol>
  
  <p>If this sounds right, then fundamentally your problem is a form of <a href="https://en.wikipedia.org/wiki/Linear_regression" rel="nofollow noreferrer">regression</a>, which something you <em>could</em> 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:</p>
  
  <p>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 <a href="https://www.r-project.org/about.html" rel="nofollow noreferrer">language like R</a> that has simple support for complex forms of regression.</p>
  
  <p>In R, this is then as simple as:</p>
  
  <pre><code>data &lt;- read.csv(file="Myfile.csv")
  lm(formula = dist ~ .*., data = data)
  </code></pre>
  
  <p>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.</p>
  
  <p>Any zero of that equation should be a pair of weapons that minimizes this difference.</p>
  
  <p>That's probably the place to start. If it doesn't work out, maybe come post a different question and we can help more.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-25T00:37:53.073Z
Answers.LastActivityDate: 2018-08-25T00:37:53.073Z
Answers.UserDisplayName: John Doucette
Body: <p>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  <span class="math-container">$N$</span> 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.</p>
  <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-07T18:29:33.437Z
Comments.Text: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/131226/discussion-on-question-by-aphrodite-which-algorithm-can-i-use-to-minimise-the-nu).
Comments.UserDisplayName: nbro
Tags: <datasets><game-ai><regression><algorithm-request>
Title: Which algorithm can I use to minimise the number of wins of 2 weapons that fight each other in a game?
UserDisplayName: Aphrodite
ThreadText: # Which algorithm can I use to minimise the number of wins of 2 weapons that fight each other in a game?
  
  (Asked by: username_0 on 2018-08-11)
  
  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.
  
  **Tags:** datasets, game-ai, regression, algorithm-request
  
  > **Comments:**
  > **username_1**: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/131226/discussion-on-question-by-username_0-which-algorithm-can-i-use-to-minimise-the-nu).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-08-25. Score: 2 | Accepted answer
  
  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](https://en.wikipedia.org/wiki/Linear_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](https://www.r-project.org/about.html) 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.
  
  
  ---
  
  