Advertisement

Football Manager sim with instant match simulation

Started by July 16, 2017 01:57 PM
8 comments, last by Aiden Gallagher 6 years, 10 months ago

I want to create a Football Manager style of game, but here's the thing: I want a rather simplistic match engine that generates instant results.

My idea is to create a game where the player can focus on managing the club and can quickly go through the seasons and see the club grow without the match simulation getting in the way.

At the same time, the match engine cannot be a simple random function that just spits out a result. It needs to take into account tactics, player skill, etc, and generate some meaningful stats for each individual player so that the (real) player can make the relevant managerial decisions, and also become attached to certain players, etc.

At first I thought that just simulating the games, without any graphics engine or live events would make it easy. But now I realize that generating meaningful individual stats and scores introduces quite a bit of complexity, and I am stuck.

I have a sheet with a few formulas but I don't know how to bring it all together. 

I am a pretty decent programmer so I think that bit will be alright. I mostly need help with this core design.

Any ideas or pointers to resources very much appreciated.

Start simple.

Assume players distributed evenly over the entire field, probably related to what the manager says it should be.

I don't know who gets the ball first, but let's assume random 50% chance. One player gets the ball. Then he will do something with the ball, pass it to another player, try to make a goal, Decide what he will do with a random number.

If it's "pass", there is a chance the opposition will get the ball, a chance that the pass will fail, and the ball leaves the field, and otherwise it ends up with the new player of the same team. Decide with the random number what will happen.

If he tries to make a goal, there is a chance the keeper will stop it, a chance it will hit some pole, etc.

Basically, you "move the ball" around between players, all the time drawing random numbers what happens. Each action takes time (or simply stop after say 100 actions or so). Statistics of the player affect the result of him doing an action. If he is an ace in long-distance goals, the chance he makes a goal will be a bit higher, and so on.

Advertisement

Thanks @Alberth

That's definitely one approach. It sounds like quite an accurate approximation of how things happen in real life.

I'm worried that it will be too complex though. Now I have to keep track of the 22 player objects, each with their own field of possibilities. But maybe like you say, I can simplify it at first, making the players static, and finding other workarounds, then gradually expanding it.

I was thinking of a completely different approach, which is to simulate in a more "holistic" way, rather than turn-by-turn.

For example, I take a midfielder, and I calculate the passes made stat with a formula like this:

passes made = random base * player skill coefficient * player condition coefficient * zone dominance coefficient

random base is a random starting number that is realistic (ex: 40-60 passes)
player skill coefficient is an adjustment based on the player's skills relevant to passing (ex: passing, technique, creativity)
player condition coefficient is an adjustment based on the player's form (mental and physical)
zone dominance is a coefficient that factors how good are the teammates in that area of the field vs the rival

So now for example imagine we model two situations:

Sit A: amazing player, good form, ok teammates
passes made = 53 * 1,4 * 1,1 * 0,95 = 78 passes

Sit B: mediocre player, ok form, good teammates
passes made = 61 * 0,75 * 1 * 1,1 = 50 passes

Then I could correlate these stats with other stats (interceptions, tackles, key passes, goal scoring opportunities, etc.) to calculate the overall match.

But maybe this will end up creating problems I cannot see now. I wonder if it will be simpler at all?

 

 

 

Well, I don't know the solution either, my post was just a first guess :)

Perhaps you should try them both, and see which one gets the best results.

 

One problem that may exist with your approach is connection between players. If you have excellent attackers near the enemy goal, but shit defenders and shit mid-fielders, the attackers will never get a ball, right? (I don't know, I never watch football, but it seems plausible :P ).

I don't know if that's relevant, but if it is, that must show-up in the formulas somewhere.

 

That's true, but that's why in my model the goalscoring chances that the attackers get would depend on the passing of the midfielders. If the midfielders aren't making key passes, the forwards don't get chances.

This brings other problems though; I would have to establish a certain sequence for how different stats are calculated (for example tackles -> passes -> shots) but it's not obvious how to do it logically (because this is such an abstract reality!)

I've researched some more and I think your approach is the most common one by far. Maybe you're right and I should try to code some very simple prototypes of both.

Do you have any recommendations on how to code it?

Following your recommendations I'm thinking of doing something like this:

* Divide the pitch in a grid (of not too many squares - one per player position)
* Each player is in a fixed position in the grid
* If the player has the ball, they can take the following actions:
- Move / dribble to another cell in the grid
- Pass
- Shoot
* There are also some additional events like fouls, injuries, corners and penalties
* The chance to take each action is calculated on some random factor + some of the player's skill and conditions
* The outcome is calculated on the player vs. the quality of nearby rivals + some randomness
* The players don't move "off the ball", they stay within their grid (so there's no AI doing fancy things in the background; if a player loses the ball, they go back to their grid)

Is this a design that might produce an OK simulation? Are there any complications that I'm not seeing?

I'm not an object-oriented design master so any recommendations from anyone so that this doesn't blow out of scope would be nice.

 

 

 

I'd drop everything but the minimal for my type of simulation, ie fixed position in the grid (both teams interleaved, for example), only passing to next player (ie no moving around), shooting to the next player or goal, and loosing the ball to the opposition (one of the nearest, or even just anyone of the opposite team). It's very limited, but it allows to get your feet wet comfortably.

If it works, I don't know, you may want to add a visualization at some point so you can see what is happening and see "weird" stuff.

As for OOP, don't bother making fancy classes, make a simple class Player with some statistics and create 22 instances, I'd even start with everybody the same statistics and the same values, as you first want to deal with passing the ball around between players, before you extend the model to something more realistic.

Advertisement

So... I recently looked at doing something small and similar.

Wrote about it here. I am using Node Js but doubt it would be hard to adapt to other language
https://aidensgallyvanting.blogspot.co.uk/2017/11/simulating-football-soccer-results.html

Will still need some work but may/may not be a good start point :)

You could have an actual, "prototype", X v Os on a football field that only exists internally.  The player never sees it.  Then you can abstractly actually "run the plays" and derive the results from that.  The player never sees this, it exists only to give you a "real" basis of what happened during each play from which to derive the results.

"I wish that I could live it all again."

So further to my last post! I created a simulation engine using node JS. 
I published it to npm this morning: https://www.npmjs.com/package/footballsimulationengine

you put in a few JSON objects (team1, team2 and pitch details) and then you can run "iterations" until the match is over. it lets you switch sides, tells you if a player is injured, who has scored etc. 

Doesn't do bookings at the moment but these are all things you can code based on the output of the module functions. 

This topic is closed to new replies.

Advertisement