I need help with adjusting my very basic football matches simulation algorithm. It doesn't need to take in account anything other than team rating (combined rating of team players). I came up with something, but the results are not very interesting: picture i.e they almost always end up (zero) - (something)
Here's the algorithm
double flagIncrementer = 0.10;
while(!flag){
if(new Random().nextDouble() <= baseChance - (homeTeamRating - awayTeamRating)){
teamAwayScore++;
boolean scoredFlag = false;
while(!scoredFlag){
for(Player player : away.getPlayerList()){
if(new Random().nextDouble() <= player.getProbabilityWeight()){
awayScorers.add(player);
scoredFlag = true;
break;
}
}
}
}
if(new Random().nextDouble() <= baseChance - (awayTeamRating - homeTeamRating)){
teamHomeScore++;
boolean scoredFlag = false;
while(!scoredFlag){
for(Player player : home.getPlayerList()){
if(new Random().nextDouble() <= player.getProbabilityWeight()){
homeScorers.add(player);
scoredFlag = true;
break;
}
}
}
}
if (new Random().nextDouble() <= flagIncrementer) {
flag = true;
} else {
flagIncrementer += 0.10; //inkrementiraj kako bi se izbjegla beskonačna petlja
}
}
It's very simple, I just generate a random number and then see if I get a number that is less than the base chance accounted for difference in team rating. I repeat that for second team. Loop can exit on the first iteration, but it doesn't have to be. If it doesn't, I increment my control variable so it has a higher chance to exit on the next iteration.
I'm not particularly adept at statistics nor math, but even directing me in the right way is very much appreciated.
for soccer games, 0 is not uncommon, I don't see what's wrong with it. But here is an alternative view: 1> determine total goals, which can poisson distribution. 2> For each of the goal, determine which team goaled, which can use the normlized team strength: A/(A+B) vs B/(A+B). I would suggest something benefit the stronger team more which seems to be more real world result.