use warnings ; use strict ; use GD::Graph::linespoints ; use Text::Flowchart ; my %position = ( 'a' => "0 , 0" , 'b' => "1 , 0" , 'c' => "2 , 0" , 'd' => "0 , 1" , 'e' => "1 , 1" , 'f' => "2 , 1" , 'g' => "0 , 2" , 'h' => "1 , 2" , 'i' => "0 , 3" , 'k' => "1 , 3" , 'l' => "2 , 3" , ) ; my @p = keys %position ; my @v = values %position ; #my @p = ('$a','$b','$c','$d','$e','$f','$g','$h','$i','$k','$l') ; my $fee ; my @point ; my $lastfee = 0 ; my $timer = 0 ; my $request = 0 ; my $tvacume = 2 ; while ($request < 180) { my $pdirty = $p [int rand @p] ; my $pvacum = $p [int rand @p] ; my @p2 = split (/\,/, ($position{"$pdirty"})) ; my @p1 = split (/\,/, ($position{"$pvacum"})) ; #print $p1[0] , $p1[1] , "\n" ; #print $p2[0] , $p2[1] , "\n" ; if ($pvacum eq $pdirty) { print 'Fee is Zero' , "\n" ; $fee = 0 ; } else { $fee = 2 * (abs (($p2[0] - $p1[0]) + ($p2[1] - $p1[1]))) ; } $timer = $timer + ($fee + 2) ; $pvacum = $pdirty ; print $request , "\n" ; #print "$fee" , ":" , "$timer" , "\n\n" ; $request++ ; #sleep (28.8) ; $lastfee = $fee + $lastfee ; push @point , \$timer , \$fee ; print $lastfee , "\t\t" ; #print @point , "\n" ; } my $graph = new GD::Graph::linespoints(500 , 500) ; $graph->set( x_label => 'Time' , y_label => 'Fee' , title => 'Time Vs Fee') or warn $graph->error ; my $diagram = GD::Graph::Data->new(@point) ; print ($graph->plot(\@point)) , "\n" ; #print header(-type=>'image/jpg') , $graph->gd->jpeg ;