#! /usr/bin/perl -w

use strict;
use lib 'blib/lib';
use qotw::Week7e;

my $vapour = 30;
my $rows   = 100;
my $cols   = 100;
my $ice    = 1;
my $verbose = 0;
my $snapshot = 20;
my $filename = 'newfrost';

my $gridsize = $rows * $cols;
my $vapourpoints = int($gridsize * $vapour / 100);

my $frost = qotw::Week7e->new( rows => $rows, cols=>$cols, ice => $ice, vapour => $vapour, verbose => $verbose );

print "Grid size = $gridsize\n";
print "Calculated vapour points = $vapourpoints\n";

$frost->export( $filename."0000.png" );

$|=1;
while (1) {
    my $loop = $frost->tick();
    print ".";
    #$frost->display();
    #sleep (1);
    if (!($loop % $snapshot)) {
        my $file = sprintf "$filename%04.0d.png", $loop;
        $frost->export( $file );
        print '|';
    }
    unless ($frost->change()) {
        my $file = sprintf "$filename%04.0d.png", $loop;
        $frost->export( $file );
        print "\nRun complete on iteration $loop\n";
        last;
    }
}
