Download the visualizer.
As usual, to interface with the local tools, you need to write a program that
reads from standard in and writes to standard out. You may debug to standard
error. Note in particular that you should only read the number of waypoints
once, not once for each double[]. When writing your output, you must be
careful to put each array on one line, starting with the number of elements,
followed by the elements themselves, with no extra spaces.
int N = 0;
double[] da(){
if(N == 0)
N = nextInt();
double[] ret = new double[N];
for(int i = 0; i<N; i++)ret[i] = nextDouble();
return ret;
}
main(){
double friction = nextDouble();
double air = nextDouble();
double maxacc = nextDouble();
double[] wx = da();
double[] wy = da();
init(friction,air,maxacc,wx,wy);
while(true){
double x = nextDouble();
double y = nextDouble();
double dx = nextDouble();
double dy = nextDouble();
double alpha = nextDouble();
int wp = nextInt();
double[] op = step(x,y,dx,dy,alpha,wp);
print(op.length);
for(int i = 0; i<length(op); i++)
print(" "+op[i]);
println();
flush(stdout);
}
}
To help you get started, you can download simple solutions that interface with
the visualizer for your language of preference:
- Car.java
- car.cpp
- Car.cs
Using the visualizer should be fairly straightforward. You can control the
parameters using the interface. You may play the game manually, or set it to
play your solution. You may also set it in two player mode, where one or both
players are computer programs, and the other player(s) are human. If playing
manually, the CTRL and SHIFT keys cause your car to turn faster.
Additionally, there is a console application that will run your solution
non-visually: Runner.exe. You can run this from the
console by executing:
Runner -friction <friction> -air <air> -maxacc <maxacc> -N <N> -seed <seed> "Your Program"
All the parameters except the last one are optional. N represents the number
of waypoints. The values of the ones you omit will be generated from the
random number generator. Thus, you can run the examples by doing something
like
Runner -seed 1 "java Car"
If you omit the seed parameters, 1 will be used.
If you output anything invalid (including accelerating or turning too much,
you should get an error message from the tools. You must be careful about
your floating point precision. If you don't use enough digits, and you round
away from 0, your output will be larger than the allowed value, and you will
receive an error.