Modeling sports matches in an online game

In an online game manager (like Hattrick ), I want to simulate the correspondence between the two teams.

The team consists of 11 players. Each player has a strength value from 1 to 100. I take these power values ​​of the defensive players for each team and calculate the average. This is the defensive quality of the team. Then I take on the strength of the attackers, and I get an offensive quality.

For each attack, I do the following:

$offFactor = ($attackerTeam_offensive-$defenderTeam_defensive)/max($attackerTeam_offensive, $defenderTeam_defensive); $defFactor = ($defenderTeam_defensive-$attackerTeam_offensive)/max($defenderTeam_defensive, $attackerTeam_offensive); 

At the moment, I don’t know why I am dividing it by the higher of both values. But this formula should give you a factor for the quality of the offense and the defense that are needed later.

Then I have nested conditional statements for every event that might happen. For example: does the attacking team have a chance to win?

 if ((mt_rand((-10+$offAdditionalFactor-$defAdditionalFactor), 10)/10)+$offFactor >= 0) { ... // the attack succeeds 

These additional factors may be, for example, tactical values.

Do you think this is a good way to calculate the game? My users say they are not satisfied with the quality of the simulation. How can I improve them? Do you have different approaches that can give better results? Or do you think my approach is good, and I only need to adjust the values ​​in the conditional statements and experiment a bit?

I hope you help me. Thanks in advance!

+6
probability simulation
source share
5 answers

This is how I do it.

Offensive / protective quality

First, let's work out the average strength of the whole team:

 Team.Strength = SUM(Players.Strength) / 11 

Now we want to split the side in half and develop an average for our defenders and our attacking players.]

 Defense.Strength = SUM(Defensive_Players.Strength)/Defensive_Players.Count Offense.Strength = SUM(Offense_Players.Strength)/Offense_Players.Count 

Now we have three meanings. The first, average result of the team will be used to calculate our chances of winning. The other two are going to calculate our chances of defense and our chances of winning.

A team with a high level of attack will have a better chance, a team with a high defense will have a better chance of salvation.

Now, if we have teams, let's call them A and B.

Team A has an average of 80 points, an offensive score of 85, and a protective score of 60.

Team B has an average of 70 points, an offensive score of 50 and a protective score of 80.

Now, depending on the average. Team A should be more likely to win. But how much?

Evaluation and Preservation

Let's find out how many times A team scored:

 A.Goals = (A.Offensive / B.Defensive) + RAND() = (85/80) + 0.8; = 1.666 

I assumed that a random value adds something between -1 and +1, although you can tweak this.

As we can see, the formula indicates that team A should score 1.6 goals. we can either get around this up / down. Or give command A 1 and figure out if another (random chance) is allowed.

Now for team B

 B.Goals = (B.Offensive / A.Defensive) + RAND() = (50/60) + 0.2; = 1.03 

So, we have a score of 1 and B scoring 1. But remember, we want it to be in favor, because, in general, they are the best team.

So what is the chance to win?

 Chance A Will Win = (A.Average / B.Average) = 80 / 70 = 1.14 

Thus, we can see that the odds are 14% (0.14) in favor of winning A. We can use this value to see if there are any changes in the final score:

 if Rand() <= 0.14 then Final Score = A 2 - 1 B Otherwise A 1 - 1 B 

If our random number is 0.8, then the match is a draw.

Rounding and further thoughts

You will definitely want to play around with the values. Remember, game mechanics are very hard to understand. Talk to your players, ask them why they are unhappy. Do teams always lose? Is modeling always stagnating? and etc.

The above diagram deeply reflects randomness of choice. You will want to normalize it, so the chances of a team to score an additional 5 goals are very rare. But a little coincidence is a great way to add some variety to the game.

There are ways to edit this method. For example, instead of the number of goals, you can use the goal figure as the number of chances to win, and then have another function that determines the number of goals based on other factors (i.e., chose a random striker and would use the players individually statistics and goalkeeper to work out if there is a goal)

Hope this helps.

+19
source share

The most basic tactical decision in football is the choice of formation , which is a set of three numbers that assigns 10 players to the defense field, midfield and attacks, respectively, for example 4/4/2.

If you use the player’s average strength, you don’t just lose this tactic, you have it in the opposite direction: the strongest defense is one with one very good player, giving him any help, which makes it more likely to evaluate the other team, If you have one player with a rating of 10, then an average of 10. Add another rating of 8, and the average frame (up to 9). But appointing more people to protect should make him stronger, not weaker.

So, firstly, you want everything to be based on a total, not an average. The balance between the outcomes is a good scale-independent way of determining which teams are stronger and how much. Relations are better than differences because they work in a predictable way with teams of any range of strengths. You can set up a battle results table , which indicates how many goals are scored (per game, half, per move or something else).

The next tactical choice is whether it is better to have one exceptional player or several good ones. You can make it so that by creating scripts that represent things that happen in the game, for example. 1 on 1, corner or long ball. Players participating in the script are first randomly selected, and then the result of the script. One result may be that another scenario begins (the transition from midfield results in the cross leading to the likelihood of a headline).

The last step that will bring you to the level of a football manager’s real games is to give players more than one type of strength rating, for example, heading, passing, shooting, etc. Then you use the strength rating corresponding to the scenario in which they are located.

+4
source share

The separation in your example is probably bad because it zooms out the output variable depending on which side is better. Typically, when comparing two values, you either want a data interval (subtract one from the other), or a relationship data (divide one by the other), but not both.

The best approach in this case would be to simply divide the offensive score by the protective score. If both are equal, the result will be 1. If the attacker is better than the defender, he will be more than 1, and if the defender is stronger, he will be less than one. These are simple numbers for work.

In addition, instead of averaging the entire team, the middle parts of the team depending on the formations or tactics used. This will allow teams to choose to play the attack or defend, and see the pros and cons of this.

And write yourself some of the best random number generation features. One that returns floating point values ​​between -1 and 1 and one that works from 0 to 1, for starters. Use them in your calculations, and you can avoid all these confusing 10 everywhere!

+3
source share

You can also ask users what they don't like. It is possible that instead of seeing the final result of the game, they want to know how many times their team had the opportunity to attack, but the defense regained control. Therefore, instead of

  "Your team wins 2-1" 

They want to see highlights:

  "Your team wins 2-1:
  - scored at minute 15,
  - other team took control and went for tried for a goal at minute 30, 
    but the shoot was intercepted,
  - we took control again and $ PLAYER1 scored a beautiful goal!
 ... etc

You can use something like what Jamie offers for the starting point, choose a random time and possibly choose who scored a goal based on a weighted selection of attacking players (i.e., a player with a higher score gets a higher chance from the one who scored). You can have fun and add random events with a low probability, such as a red card on a player, someone injures himself, prostitutes all over the field ...

+3
source share

There should be an average number of players ... using the maximum value if you have 3 teams of players:

[4 4 4]

[7 4 1]

The second will be considered weaker. Is this what you want? I think you would rather do something like:

(Total Points / Total Players) + (Max Score / Total Players), so in the example above, this will make the second team a little better.

I think it depends on how you feel that the teams should be balanced.

0
source share

All Articles