Spring Challenge 2021 - Bugs & Questions

From the rules:

To perform a seed action, you must pay sun points equal to the number of seeds (size 0 trees) you already own in the forest.

I.e., the first seed is free. To seed once more costs 1 sun point if the first seed remains. The next seed costs 2 sun points if the previous two seeds remain.

3 Likes

C++ Clock Query

My basic understanding of clock() is that if I take the difference in values and divide by the CLOCKS_PER_SEC, then I get the elapsed time in seconds.

elapsedInSeconds = (finish-start)/CLOCKS_PER_SEC

Doing this Iā€™m getting a typical elapsed time per turn of 0.000256 seconds with 2 or 3 trees. However, when the number of trees increases to 4, I exceed the time to provide a response. If I simplify the analysis then I can have more trees, but still only achieve a maximum elapsed time of 0.00026 seconds per turn.

Am I correct in how to calculate elapsed time in C++?

I think there might be because it was possible for some challenge (for AI training or local debugging itā€™s great). you could dig from there maybe ? https://www.codingame.com/forum/t/what-is-exactly-the-referee-and-so-engine/39234

I think most people use chrono::high_resolution_clock for this.

1 Like

From the rules:
"
To perform a seed action, you must pay sun points equal to the number of seeds (size 0 trees) you already own in the forest
"
And now i see that someone allready answered thisā€¦I donā€™t see all the questions&replies through my mobile for some reason.

1 Like

We have pushed a fix for the gray viewer. Let me know if someone still encounters the issue.

I still have the issue

MacOS Catalina 10.15.2
2 GHz Intel Core i7 quatre cœurs
Intel HD Graphics 3000 512 Mo
Chrome Version 90.0.4430.93 (Build officiel) (x86_64)

HW accel enabled in Chrome

There are a lot of us waiting to be promoted to silver, we seem to be stuck.

4 Likes

Yes! We were caught testing in the arena when the split of categories and many of us are stuck in Bronze

1 Like

Same here, I was ranked about 100th before the splitā€¦
Since I was stuck above the boss for a long time, I resubmitted (just in case) 2h ago and it did not help.
I am still stuck way above the boss
Is there any hope to get promoted this evening?

Staff are aware of the situation and are working on it.

1 Like

Solved!!! Thanks

Thank you!

Hi, is there an easy way to play by hand (without coding) against myself ? It would be very helpful in order to develop a strategy.

I donā€™t know if this is expected, but the discord school channel has disappeared from the discord sidebar, even after refreshing page.

As with every multiplayer or optimization game, Iā€™m running into timeout issues again, mostly due to trying to deal with garbage collection. This particular issue I ran into is a little weirder than most, though. Any ideas whatā€™s going on? Iā€™m using a Monte Carlo tree search algorithm (for future reference, I find that MCTS is too slow due to the sheer number of SEED actions to actually be effective in this game except for the last 2 days).

Hereā€™s the skeleton C# code for the main loop:
main() {

Stopwatch sw = new Stopwatch()
bool firstTurn = true;

while (true) {

sw.Restart()
ResumeMCTS(... for 945 or 60 ms...)

if (sw.ElapsedMilliseconds < 90)
Thread.Sleep((int) (90 - sw.ElapsedMilliseconds));

!! if (firstTurn && sw.ElapsedMilliseconds < 990)
Thread.Sleep((int) (990 - sw.ElapsedMilliseconds));

Console.WriteLine(... my action ...)

// the rest of the loop
// including reading input and figuring out opponent's move
}

My ResumeMCTS() function stops running after 945 ms on the first turn (or 60 for the rest), allowing for 30-50 ms of garbage collection before every output during the Thread.Sleep() calls (these numbers are empirically determined to reduce the number of timeouts in the arena to < 5% of games).

In my previous multiplayer games, I didnā€™t have the !! statement, but this time I decided to include it so that GC can get an opportunity after the first turn. When the statement is included and I play against myself in the IDE, there is no issue. However, when I submitted it to the arena, my algorithm would time out before the first Console.WriteLine(), so I would be immediately disqualified. The weird thing, though, is that it only happens if I am player 2 (blue).

Obviously I can just take it out of my code for the submission (which is my current submission), but it boggles the mind. Fundamentally, my real question is am I timing my algorithm to avoid timeouts correctly?" This timeout issue has been really annoying to deal with in my past multiplayer games, and it would be nice if I can solve it once and for all. Itā€™s so difficult to figure out the constraints, especially because of things like the IDE being fine with running a turn for 110 ms, when it clearly shouldnā€™t be (and the arena gives me a timeoutā€¦ but only sometimes).

I reached Bronze league on my own (in java) and then I used Starter AI from the Starter Kit.

Now I am very confused how to proceed because the ā€œstarter kitā€ is so complex.
Please someone add some more hints in the starter kit so that we can proceed further in the game!

Problem is fixed !!!
Thanks a lot !! :slight_smile:

Grey screen issue still there: only works the first time Chrome is launched. If I change of tab in Chrome then grey screen comes back.

MacOS Catalina 10.15.2
2 GHz Intel Core i7 quatre cœurs
Intel HD Graphics 3000 512 Mo
Chrome Version 90.0.4430.93 (Build officiel) (x86_64)
HW accel enabled in Chrome

Your skeleton code doesnā€™t make it clear where you read the inputs - the stopwatch has to be restarted after the inputs are read (ideally after the first input is read for the most accurate timing, but usually the input code is quick enough that it doesnā€™t make much difference). The only time the server can measure is the time between giving you input and receiving output and if you start the stopwatch before the first input statement youā€™ll sit waiting for inputs while the stopwatch is running.

Iā€™d never try to go so close to the limit on the first turn (I generally stick to 900ms). The 1 second limit is there more to let your program get started than for extra calculation (especially for JVM based codes there are often delays the first time things are run - not sure if this applies for c#).

Iā€™m not really a c# user but in many languages there are ways to force garbage collection rather than sleeping and hoping it runs (quick google suggests GC.Collect()?).

1 Like