Simplefootball - The idea

in #programming6 years ago

In my introduction I said that I would also present some of my programming and today we will get started with that. The program I want to talk about is a simple football (soccer) simulation that I have been occasionally working on in the past half year or so and appropriately named simplefootball. Rather than look at lots of code (which is in C++ by the way) I would like to focus on the ideas and concepts that went into it.

For the first part we will look how the result of a game will be generated. I actually got the idea for the entire project when I read about this method somewhere. The trick is to break down the somewhat continuous game into (a finite number of) single blocks that will be processed one after the other. Maybe the most obvious way to do this is to use the 90 minutes of the game as such blocks. Looking at a single minute there will be a certain chance for each team to score in this minute. This will, of course, depend on the offensive and defensive qualities of the teams, their formation, how fit the players still are and tons of other factors but we will worry about that later. One thing this will not replicate is that the chance might be influenced by what happened in the minute before, for example if one team got a penalty it is nearly certain that they will score in the next minute. This is not really a big problem though. If you want, you can think of a penalty as “80% of a goal” and by this it is more or less included in the chance to score.

To obtain the chance of one team scoring in a single minute we will first take the teams offensive strength (based on the factors mentioned above and maybe some more) and divide it by the opponents defensive strength (depending on similar factors). In a fair match this value will be around 1 = 100%. Since it is rather unrealistic for both teams to score almost every minute we will divide this by a global value I call MINPERGOAL which says how many minutes it takes on average to score for any team. If it were 90 we would expect the “average” game to end exactly 1:1. I am not exactly sure what this should be set to but for the most part it will be between 70 and 80, resulting in 2 to 3 goals per game on average (keep in mind that there are two teams). All this results in a chance of a little over 1% for the team to score in a given minute (in a fair match).

Now that this is figured out we will just do this simulation of one minute ninety times, add up all goals scored for either team and by this get a fairly reasonable simulated result of a football game.
One last technicality is that if both teams should score in one minute then no goal is awarded at all since I found it unrealistic for two goals to occur in one minute and this is very unlikely anyway.

Incidentally I rigged up a version of simplefootball to play two identical teams against each other multiple times prior to the world cup so now we can look at the results with MINPERGOAL set to 100:
009_sf1_1.JPG
and how they change when it is set to 60:
009_sf1_2.JPG

Sort:  

Hi, steemchess is calling!
Sorry for interrupting, but I have some news for you:
https://steemit.com/steemchess/@schamangerbert/steem-world-chess-championship-2020-january-3-5

It would be great if you participate, good luck!


You just planted 0.09 tree(s)!


Thanks to @jifka

We have planted already
7280.03 trees
out of 1,000,000


Let's save and restore Abongphen Highland Forest
in Cameroonian village Kedjom-Keku!
Plant trees with @treeplanter and get paid for it!
My Steem Power = 27161.00
Thanks a lot!
@martin.mikes coordinator of @kedjom-keku
treeplantermessage_ok.png

Congratulations @jifka! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.038
BTC 95634.12
ETH 3333.35
USDT 1.00
SBD 3.08