-
Notifications
You must be signed in to change notification settings - Fork 0
/
gmin.pl
53 lines (44 loc) · 912 Bytes
/
gmin.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -w
use strict;
# gmin.pl taille densite nb home name end name
if (scalar @ARGV < 3)
{
print "usage : gmin.pl size density nb_of_fourmiz\nWhen size is the number of rooms and density the percentage of probability of connexions between rooms\n";
exit -1;
}
my $i = 0;
my $j = 0;
my $size = shift @ARGV;
my $density = int(shift @ARGV);
my $nb = int(shift @ARGV);
my $home = int(rand($size));
my $end = int(rand($size));
while ($end == $home)
{
my $end = int(rand($size));
}
print $nb . "\n";
while ($i < $size)
{
print "##start\n" if ($i == $home);
print "##end\n" if ($i == $end);
print $i;
print " " . int(rand(10 * $size));
print " " . int(rand(10 * $size));
print "\n";
$i++;
}
$i = 0;
while ($i < $size)
{
$j = 0;
while ($j < $size)
{
if ($density > int(rand(100)))
{
print $i . "-" . $j . "\n";
}
$j++;
}
$i++;
}