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 & 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)

  • 1
    $\begingroup$ This doesn't affect the core answer, but might affect advice about follow-up: In a play by humans, is there any skill involved (button pressing, or tactics in a turn-based game) that may affect the outcome? E.g. for weapon optimised for near range, high damage, does player have opportunity to stay in close melee through use of movement or the environment? Also, I would assume one of your goals is to have the weapon stats different in that they cover a wide range of stats? Please make that clear, because many optimising techniques will end up with 2 or more weapons with near identical stats. $\endgroup$ Aug 11 '18 at 8:21
  • $\begingroup$ @NeilSlater The combat is now simply robotic, there are no range or anything like that, the combat is turn based, as the game is text based. I would not mind having an algorithm that gives similar weapon stats, as I can always find a pair that doesn't. $\endgroup$
    – Aphrodite
    Aug 11 '18 at 10:42
  • $\begingroup$ @pasabaporaqui The 1 is the number of WInWeapon1-WinWeapon2, but is often bigger. The 1s and 2s are also randomised, from 1 to 100. $\endgroup$
    – Aphrodite
    Aug 11 '18 at 11:50
  • $\begingroup$ There are some other important details, that would significantly change an answer (I am thinking this through in the hope I may be able to answer). Mainly to do with how multiple pairs will work. Expecting weapon A and B to pair might be reasonable, but then if C pairs with A, it might not pair with B - whether that holds logically or is even possible depends entirely on your combat system. $\endgroup$ Aug 12 '18 at 10:42
  • $\begingroup$ Also, do you want to have multiple pairs of weapons at different tiers of weapon strength, and if so are you expecting them to out-perform predictably? A pairs with B, C pairs with D, if you match A vs C, C wins by expected 10 points - would you also expect A vs D, B vs C and B vs D to also have the weapon from the second set to win by an expected 10 points? Questions like this might end up with you needing to alter the combat system itself (as opposed to just the weapon stats), in order that it support these equivalences. $\endgroup$ Aug 12 '18 at 10:44

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.