Advertising Visualization

To aid in the development of your submission, we are providing a visualization tool to competitors. 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 Ads.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 standard in. Once you have read the parameters, you should write your return values to standard out. More specifically, the first three lines you read will give you the parameters competitor, adCost, and N. The next two lines will give you x and y, where each line contains N numbers, delimited by spaces. After these initial parameters, you will repeatedly read the parameters to update, and output your return. As with reading x and y, you should first read the length of index and product, and then read two lines, with that many integers in them. You should then output the number of ads you wish to place in this time step, followed by that many ads, each on a single line.

For instance, to use the visualizer, you might implement the following pseudocode, and adapt your solution to use it:
        competitor = double(nextLine())
        adCost = double(nextLine())
        N = int(nextLine())
        sx = tokenize(nextLine())
        sy = tokenize(nextLine())
        for(i = 0; i<N; i++)
            x[i] = double(sx.nextToken())
        for(i = 0; i<N; i++)
            y[i] = double(sy.nextToken())
            M = int(nextLine())
            si = tokenize(nextLine())
            sp = tokenize(nextLine())
            for(i = 0; i<M; i++)
                index[i] = int(si.nextToken())
            for(i = 0; i<M; i++)
                product[i] = int(sp.nextToken())
            ads = update(index,products)
            for(i = 0; i<length(ads); i++)

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 Ads.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 advertising 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 Advertising.class, you should enter something like "java Advertising" (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 Ads.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 black dots are people who haven't purchased either, while green have purchased your product, and red is your competitor. The blue arrows are your ads.

You may customize the game by entering any values for the parameters that you like, and then clicking generate map to make a new map. The field seed is a seed for the random number generator and will allow you to repeatedly generate the same map (note, however, that seed 0 means to use time as a seed). Clicking the "Generate Map" button will generate the map based on your parameters. Alternatively, you can select new random values for all 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 parameters as well as the map, otherwise a new seed will be generated. To test the examples from the problem statement, you may simply enter the seeds 1-10, corresponding to examples 0-9, and click "New Parameters and Map".

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 Ads.jar -N 5000" will set N to 5000 when running the tool.
-height <height> Specify the initial height of the window
-width <width> Specify the initial width of the window
-competitor <competitor> Specify competitor
-adCost <adCost> Specify adCost
-K <K> Specify K
-N <N> Specify N
-C <C> Specify C
-D <D> Specify D
-radius <r> Specify the radius of the circles used for people
-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