A*Craft Puzzle discussion

Feel free to send your feedback or ask for some help here!

Nice to have it that fast after the contest, well done :slight_smile:
Also FYI looks like its leaderboard is missing in the optim category of the leaderboard dropdown.

3 Likes

How to get my score given the referee and my player (to try models locally)? I cloned the repository but I don’t find how to simply get my score on each test cases without the graphical interface (on localhost:9999)? Got sample code (in java)?
Thanks. :wink:

try replacing gameRunner.start() with gameRunner.simulate() in the Main. It won’t launch the interface and there will be a score in the return of the function in a map called “metadata”

1 Like

It worked!! Thank you _CG_jupoulton.
In the class com.codingame.gameengine.runner.dto.GameResult.Main I replaced the code
gameRunner.start(9999);
by
GameResult gameResult = gameRunner.simulate();
System.out.println( gameResult.metadata );

and I get {“Points”:“65”} in the console

That’s what I did during the contest, allows you to run all tests at once: Github.
You can also run a test multiple times with an average score if you want.

I changed two other files as well, you may want to clone the whole repo.

1 Like

Yes eulerscheZahl it runs OK, but it needs to set the input in that json pattern. For example:
{
“title”: {
“1”: “Divisé”,
“2”: “Split”
},
“testIn”: “#R…l…D#\n#…r…#\n#…l…#\n#…r…#\n#dudududu#udududud#\n#…r…#\n#…l…#\n#…r…#\n#U…l…L#\n###################”,
“isTest”: “true”,
“isValidator”: “true”
}

Is there a way to run the simulation directly with what we get as game input? For example like
#########.#########
#########D#########
#########.#########
#########.#########
…R…R…
#########.#########
#########.#########
#########D#########
#########.#########
#########.#########
1
10 4 R

And get the result score…
Thanks.

I don’t see the problem with the json format: the referee loads the json file and converts it to the format expected by your bot.
The only problem I can imagine is when you want to create your own testcases.

@ eulerscheZahl It needs to convert from what I get as input to the JSON: arrows to lower case and robots to their position and orientation in upper case (no problems if I want to create my own test case knowing thoses rules)… This is just one more step! I’d like to use the referee as I play one CodinGame : I put the inputGame in my code given my player and I get the score… just simply, without to have to implement a kind of “middleware” between the CodinGame given code and what I have to submit.

Is there an error with the Results - Details page, it says every Validator passes successfully (green), even if there is an error or timeout?

That’s a feature added for the contest: imagine you fail one test in the rerun and suddenly rank below 1000 with a strong code. Passing everything ensures that you will only be sorted by score, not the the number of passed validators.

1 Like

Validators 17 (Cells) and 28 (The Best Way) are always invalid!!!

Tried my old solution from Oct. 18 and a dummy solution (code writes just newline)
and get only 93% instead of 100%.
All test cases work fine!
Any ideas?

3 Likes

Thank you for reporting the issue. Should be working now.

yep, thx!!!

insignificant comment, but there’s a typo:
“1 character direction, the direction if faces (U, R, D or L).”

should probably be “it”

1 Like

The default code in C doesn’t read input correctly, the size of line should be 21 instead of 20.

Related to https://www.codingame.com/forum/t/problem-with-c-stub-in-contributions/186525

In Java, is it normal than just parsing inputs takes around 2s…

I tried two technique, the usual one with Scanner and an other one with DataInputStream to speed up the process. Both take around 2s.

When parsing I create 10*19 + $nb_of_robots objects and two boolean arrays, that’s not that big.
I tried to profile the code with VisualVM on my machine and could not find any bottleneck on this method.

edit:
I found the 2s with the following method:

long start = System.nanoTime();
readInputs();
System.err.println("after read " + (System.nanoTime() - start));

Which result to “after read 1890680780” = ~2s

readInputs method:

        Scanner sc = new Scanner(System.in);
        int platformCount = 0;
        for (int i = 0; i < 10; i++) {
            String[] line = sc.nextLine().split("");
            for (int j = 0; j < line.length; j++) {
                CellType cellType = CellType.valueOfLabel(line[j].charAt(0));
                int id;
                if (cellType.canBeModified()) {
                    id = platformCount * 4;
                    platformCount++;
                } else {
                    id = -1;
                }
                intialMap[i][j] = new Node(id, j, i, cellType);
            }
        }

        int robotCount = sc.nextInt();
        robots = new Robot[robotCount];
        neverMutatedRobots = new Robot[robotCount];
        robotsStatus = new boolean[robotCount];
        aliveRobotsCount = robotCount;
        boolean[] historic = new boolean[platformCount * 4];
        for (int i = 0; i < robotCount; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            String direction = sc.nextLine();
            CellType cellType = CellType.valueOfLabel(direction.charAt(0));
            robots[i] = new Robot(x, y, cellType, historic);
            neverMutatedRobots[i] = new Robot(x, y, cellType, historic);
            robotsStatus[i] = true;
        }

I saw you did a good score in Java, may I ask if you have the same issue?
@wala @LaurentTrk @Redstrike

Quick question, are you profiling your parsing on the first turn? Do you get similar results if you profile a later turn?

In this game there is only one turn (if I understood correctly).
You basically read inputs then do some computation to output the map configuration you want.