ImageReconstruction Visualization

To aid in the development of your submission, we are providing a visualization tool to competitors. This tool is provided as is, with no guarantees of any sort. The tool is packaged as an executable jar, which can be run either by double clicking it (in windows anyway) or from the command line as "java -jar Reconstruct.jar".

As in previous contests, to use this visualization tool, you should create an application that communicates with the tool via standard in and standard out. Note that this does not effect the way your program should work when you submit it on the TopCoder website. The program that you write for the visualizer should start by reading the parameters from the standard input stream. Once you have read the parameters, you should write your guesses to standard out. The visualizer will attempt to read rows*columns integer from your program's output stream (separated by whitespace).

When reading the parameters, the first line will contain three integers: pieceSize, columns, and rows separated by spaces. This will be followed by pieceSize*pieceSize*rows*columns lines containing the values of the pixels in the same way they are given when submitting normally.

After each guess, you should read a string of rows*columns zeros and ones, with no spaces, specifying which pieces are in the right place, as when you call the verify method.

Here is an example of what your wrapper code might look like. Your main method could read the parameters and then pass them to your reconstruct method (which would be unchanged between your visualizer code and your submission code, except for the call to verify). The verify method will then write your guesses to standard out and retrieve the results. The readString and readInt methods will simply retrieve the next integer or string from standard input, ignoring whitespace (there are library functions for this in most languages).
    verify(int [] p)
        ret = int[rows*columns]
        for(i = 0; i<length(p); i++)
            print p[i]
            print ' '
        print '\n'
        s = readString()
        for(i = 0; i< rows*columns;i++)
            ret[i] = s[i] - '0'
        return ret

        pieceSize = readInt();
        columns = readInt()
        rows = readInt()
        pixels = int[pieceSize*pieceSize*rows*columns]
        for(i = 0; i < pieceSize*pieceSize*rows*columns]; i++)
            pixels[i] = readInt()

Using the visualizer

To use the visualizer, you must have Java 1.5 or greater installed. To run the visualizer, you can execute the command "java -jar Reconstruct.jar". This will open up a new window containing the visualization, along with a number of controls. The first thing you will need to do is specify the executable you have made for your rover code. You may either enter its path, or select it via the button provided. If your executable requires arguments, enter them in the provided field. For example, if your executable is a Java class ImageReconstruction.class, you should enter something like "java Reconstruction" (without the quotes) in this field (replacing "java" with the full path to the Java executable if necessary). The exact details of what you enter here will depend on your language choice. In particular, in Java, you will need to make sure that the class file is in the same directory as Reconstruct.jar, or else you will need to specify a classpath along with the executable location and class name.

Once you have the executable set properly, you can run the simulation. You may customize the test case by entering any values for the parameters that you like, and then clicking generate map to regenerate a scrambled image. The field seed is a seed for the random number generator and will allow you to repeatedly generate the same initial scrambling. Clicking the "Generate Map" button will generate the map based on your parameters. Alternatively, you can select new random values for the seed and size parameters by clicking "New Parameters and Map". If you've changed the seed, since you last generated a map, the seed you entered will be used to generate the size as well as the scrambling, otherwise a new seed will be generated. To test the images from the problem statement in the same way they are tested by the TopCoder system, you need to download the PNG files, and make sure to use the right seed and piece size.

Once you've started the simulation, any output you write to standard error, along with messages from the visualization tool will appear in the text area below the visualization. You may control the speed with the slider on the top.

Command Line Options

You can specify a number of parameters on the command line to simplify the automation of testing (though you don't need to use any of them). For example, "java -jar Mars.jar -rovers 50" will set noOfRovers to 50 when running the tool.
-height <height> Specify the initial height of the window
-width <width> Specify the initial width of the window
-pieceSize <s> Specify the piece size
-file <A> Specify the image file
-seed <seed> Specify the initial seed
-speed <speed> Specify the initial speed
-exec <command> Specify the command to execute your code
-novisRun the test case without the visualizer (requires -exec, implies -go)
-goStart running immediately (requires -exec)
-dropTell the visualizer to drop frames if it can't keep up

Final Notes