formulas to maximize the output

73 Views Asked by At

Good day, I have a math problem in my game development like this:

I have two numbers (football player skills): Attack skill (AS) and Defend skill (DS). They are in range from 1.0 to 8.0... now I want to create formulas for every position, that would return the max value for:

  • attacker if the AS is max and DS is somwhere around 20% of max (2)
  • defender if the DS is MAX and AS is 20% of max
  • midfielder if the AS and DS are equal (higher values both of them are better)...

every other AS and DS should be worse for the given position...

I want this to calculate the best position for the player, for example:

player1 AS=8, DS=2 - best skills for attacker, so the rating should be biggest for this position. For midfielder it should be lower and for defender even more lower

player2 AS=8, DS=4 - not the best attacker, but he has close attacker rating to player1. He has a little higher midfielder rating than player1. But still the attacker rating should be better than midfielder rating. He has also higher defender rating than player1, but the grow is not as big as in midfielder rating

player3 AS=8, DS=5 - not the best midfielder, nor attacker but the rating should be similar for both positions, but not as good as player2 has attacking rating, nor as good as player4 as midfielder

player4 AS=8, DS=6 - similarly to player2 but with switched positions, so better midfielder than attacker

player5 AS=8, DS=8 - best midfielder. And there is a problem with my tries, I couldnt make this worse attacker rating than player1

player6 AS=2, DS=8 - best skills for defender

some other examples

  • AS=8 DS=8 midfield rating should be equal than attacker rating AS=8 DS=2 and equal as defender rating for AS=2 DS=8
  • AS=8 DS=8 attacker/defender rating should be equal to midfielder rating for AS=8 DS=2 or AS=2 DS=8
  • AS=5 DS=5 is a little better midfielder rating than would be AS=7 DS=5 (i know maybe weird)
  • AS=7 DS=5 can be equal midfielder rating as AS=4 DS=4 (they are both 2 points away from AS=5 DS=5)

my tries were like: AR = 0.75AS + 0.25DS

the problem was the attacker 8 8 was better then 8 2 and very few combinations give me best rating for midfielder then i tried

AR = 0.9(AS - DS) + 0.1(DS-AS) and such things but i think it will be something more complicated :(

I hope it is clear enough (EN is not my mother lang) and that there are no collisions in my rules, if you need more examples, ore some concrete, feel free to ask in comments, i will update the question

thanks everyone for help

PS: not sure if I choosed the tags correctly