//Teamstrength (nicer version)(without extra coms) public class Teamstrength implements ELO { //Map ratings = new HashMap(); @Override public List predictResult(List> teams) { return teams.stream().map(t -> (t.stream().mapToDouble(x -> (Math.pow(10,ratings.get(x)/400))).sum().getAsDouble() / teams.stream().flatMap(x -> x.stream()).mapToDouble(x -> (Math.pow(10,ratings.get(x)/400))).sum().getAsDouble() )).collect(Collectors.toList()); } //------------ //another implementation of predictResult to return single doubles: //@Override public double predictResult(List> teams, Collection team) { return (team.stream().mapToDouble(x -> (Math.pow(10,ratings.get(x)/400))).sum().getAsDouble() / teams.stream().flatMap(x -> x.stream()).mapToDouble(x -> (Math.pow(10,ratings.get(x)/400))).sum().getAsDouble())); } //------------ @Override public void evaluateResult(Collection> winnerTeams, Collection> loserTeams) { //winnerTeams and loserTeams are combined to use it in predictResult, but I'm not sure if this works with stream.concat (Collection.addAll does not necessarily work because it's an optional operation): winnerTeams.stream().forEach(t -> t.stream().forEach(x -> ratings.put(x, ratings.get(x) + 32*(1-predictResult(stream.concat(winnerTeams.stream(),loserTeams.stream()).collect(Collectors.toList()), t))/t.size()) ); loserTeams.stream().forEach(t -> t.stream().forEach(x -> ratings.put(x, ratings.get(x) + 32*predictResult(stream.concat(winnerTeams.stream(),loserTeams.stream()).collect(Collectors.toList()), t)/t.size()) ); } }