Давайте начнем с OOP:
public class Team{
private double /*int*/ strength;//Change the datatype, by your favors
private double formOfLastFiveMatches;//0 for lost all, 1 for won all, 0.6 for won 3 of 5
private Random random; //For the randomness
//...Constructors, Getters,Setters
}
Это модели вашей команды. Теперь начнем с вычисления совпадения.
public class SoccerSimulator{
private Team a,b;
//...Constructors, Getters,Setters
/**
* Calculate the probability, that A wins.
* @return the probability, A wins.
*/
public double calculateProbability(){
double strengthA = a.getStrength();
double strengthB = b.getStrength();
if(a.getForm() <= 0.2)
strengthA *= (1 + (Math.random % 0.1));//Up to 10% bonus, because they won only 0-1 games in the last 5 games
if(b.getForm() <= 0.2)
strengthB *= (1 + (Math.random % 0.1));
//Do something with the random number generator
//....
//TODO: Better algorithm
double sum=strengthA + strengthB;
return strengthA / sum;//Get the fraction A has in relationship to the sum.
}
}
Это довольно базовый алгоритм c, но вы можете использовать его в качестве отправной точки.