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.
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++?
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.
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?
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!
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()?).