package ch.fadre.sandhills;

import java.awt.image.BufferedImage;
import java.io.IOException;

public class Main {

    public static final int width = 750;
    public static final int height = 750;
    public static final int ITERATIONS = 1000_000;

    public static void main(String[] args) throws IOException, InterruptedException {

        SandSimulation sandSimulation = new SandSimulation(width, height, ITERATIONS);
        short[][] result = sandSimulation.performSimulation();

        ImageWriter imageWriter = new ImageWriter();
        BufferedImage bufferedImage = imageWriter.generateImage(result, width, height);
        imageWriter.writeToFile(bufferedImage, "test");
        imageWriter.displayInFrame(bufferedImage);
    }


}

@@ -123,30 +123,24 @@
 blic static 
-final 
 int width = 
@@ -139,18 +139,18 @@
 width = 
-75
+10
 0;%0A    p
@@ -158,30 +158,24 @@
 blic static 
-final 
 int height =
@@ -179,10 +179,10 @@
 t = 
-75
+20
 0;%0A 
@@ -202,35 +202,33 @@
 tic 
-final int ITERATIONS
+long iterationCount
  = 100
-0
 _000
@@ -315,16 +315,618 @@
 eption %7B
+%0A        if(args == null %7C%7C args.length == 0) %7B%0A            System.out.println(%22Warning: No parameters set, using defaults%22);%0A            showUsage();%0A        %7D else if (args.length == 3)%7B%0A            width = Integer.parseInt(args%5B0%5D);%0A            height = Integer.parseInt(args%5B1%5D);%0A            iterationCount = Long.parseLong(args%5B2%5D);%0A            System.out.println(%22Starting simulation with grid (%22 + width+%22w/%22 + height +%22h) and %22 + iterationCount + %22 iterations...%22);%0A        %7D else %7B%0A            System.out.println(%22Too many parameters given! Using defaults%22);%0A            showUsage();%0A        %7D
 %0A%0A      
@@ -997,18 +997,22 @@
 ht, 
-ITERATIONS
+iterationCount
 );%0A 
@@ -1329,11 +1329,119 @@
 %0A    %7D%0A%0A
+    private static void showUsage() %7B%0A        System.out.println(%22Usage: gradle run 500 500 10000%22);%0A    %7D%0A%0A
 %0A%7D%0A

Allow to pass parameters as programm arguments