ShapePackaging 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 Packing.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.

For each piece to be placed, you should first read the state of the board, followed by the piece. Each will be formatted as:
    N M
For instance, the input for one move might be as follows:
10 10
2 4
After reading the information for each placement, you should write a single line with three integers, indicating the location to place the piece. These three integers should be in the same order that you would return them from your placeTile method. After each placement, you should read the board state and next piece from standard in.

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 placeTile method (which would be unchanged between your visualizer code and your submission code).
            board = readStringArray();
            piece = readStringArray();
            placement = placeTile(board,piece)
            if(length(placement) == 0)
            print(placement[0]+" "+placement[1]+" "+placement[2]+"\n")

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 Packing.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 ShapePackaging.class, you should enter something like "java ShapePackaging" (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 Packing.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. 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, otherwise a new seed will be generated. To test the examples from the problem statement in the same way they are tested by the TopCoder system, you just need to use the same seeds.

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.

In addition to the automated testing provided by the visualizer, you may play the game manually using the visualizer. Simply click the "Manual Play" checkbox and hit start. You place pieces by left clicking and rotate by click the second and third (wheel) buttons.

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 Packing.jar -cols 10" will set cols to 10 when running the tool.
-height <height> Specify the initial height of the window
-width <width> Specify the initial width of the window
-cols <r> Specify the number of columns
-rows <c> Specify the number of rows
-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