import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Random;

public class TestGen {

    static final ArrayList<String> STRATS = new ArrayList<String>() {{
        add("random");
        add("flow");
    }};

    static Random rnd = new Random(3);

    static class TestWriter {
        final String root;
        int tests = 0;

        TestWriter(String path) {
            File root = new File(path);
            if (!root.exists()) {
                System.err.println("Creating directory <" + path + ">");
                root.mkdirs();
            }
            this.root = path;
        }

        void write(Test t) throws FileNotFoundException {
            String testNo = String.format("%02d", ++tests);
            PrintWriter out = new PrintWriter(root + "/" + testNo);
            System.err.println("Writing test (" + root + ") #" + testNo);
            out.println(t.strat);
            out.println(t.seed);
            out.println(t.n + " " + t.m);
            out.close();
        }
    }

    static class Test {
        Test(String strat, int seed, int n, int m) {
            this.strat = strat;
            this.seed = seed;
            this.n = n;
            this.m = m;
        }

        final int n, m;
        final int seed;
        final String strat;
    }

    static Test test(String strat, int seed, int n, int m) {
        return new Test(strat, seed, n, m);
    }

    public static void main(String[] args) throws FileNotFoundException {
        final Random rnd = new Random(3);
        TestWriter tests = new TestWriter("../tests");
        tests.write(test("random", 1, 3, 3));
        for (String strat : STRATS) {
            for (int n : new int[] {3, 4, 5, 6, 10, 15, 20}) {
                for (int m : new int[] {3, 4, 5, 6, 10, 15, 20}) {
                    tests.write(test(strat, rnd.nextInt(), n, m));
                }
            }
        }
    }
}
