#!/usr/bin/perl use strict; use warnings; # The following statistics are from # http://www.fifa.com/en/mens/statistics/index/0,2548,All-May-2006,00.html my %FIFA_points = ("Brazil" => 827, "Czech Republic" => 772, "Holland" => 768, "Mexico" => 758, "Spain" => 756, "USA" => 756, "Portugal" => 750, "France" => 749, "Argentina" => 746, "England" => 741, "Italy" => 728, "Sweden" => 709, "Japan" => 705, "Germany" => 696, "Tunisia" => 693, "Iran" => 686, "Croatia" => 686, "Costa Rica" => 683, "Poland" => 677, "South Korea" => 677, "Ivory Coast" => 669, "Paraguay" => 653, "Saudi Arabia" => 651, "Switzerland" => 648, "Ecuador" => 631, "Australia" => 612, "Serbia & Montenegro" => 610, "Ukraine" => 609, "Trinidad & Tobago" => 604, "Ghana" => 600, "Angola" => 581, "Togo" => 569 ); my %groups = (A => ["Germany", "Costa Rica", "Poland", "Ecuador"], B => ["England", "Paraguay", "Trinidad & Tobago", "Sweden"], C => ["Argentina", "Ivory Coast", "Serbia & Montenegro", "Holland"], D => ["Mexico", "Iran", "Angola", "Portugal"], E => ["USA", "Czech Republic", "Italy", "Ghana"], F => ["Australia", "Japan", "Brazil", "Croatia"], G => ["South Korea", "Togo", "France", "Switzerland"], H => ["Spain", "Ukraine", "Tunisia", "Saudi Arabia"] ); my @combinations = ([0, 1], [2, 3], [0, 2], [3, 1], [3, 0], [1, 2]); for ("A" .. "H") { print STDERR "\nGroup $_:\n"; my $group = $groups{$_}; foreach (@combinations) { my $a = $group->[$_->[0]]; my $b = $group->[$_->[1]]; my $home_advantage = $FIFA_points{$a} - $FIFA_points{$b}; my $score = get_score($home_advantage); print STDERR "$a vs $b ($score)\n"; } } sub get_score { my ($points_diff) = @_; my $score = 0; my $other = 0; if (abs $points_diff <= 30) { $score = 0; } elsif (abs $points_diff <= 80) { $score = 1; } elsif (abs $points_diff <= 130) { $score = 2; } elsif (abs $points_diff <= 200) { $score = 3; } else { $score = 4; } my $random_factor = rand; if ($random_factor > 0.9) { $score += 2; $other += 2; } elsif ($random_factor <= 0.9 and $random_factor > 0.75) { $score += 1; $other += 1; } if ($points_diff == abs $points_diff) { return "${score}-${other}"; } else { return "${other}-${score}"; } }