Death First Search - Episode 1 - Puzzle discussion

You can replay the behavior of your code in the submitted ide. Which behavior do you lose with? Do you severe the wrong link? Does it stop working for “no reason”?

I can replay and It stopped working for no reason at all, than it gave me the message.
It did not reach the gateway very strange

I can you the code in a private message or something?

I would prefer not to, sorry :wink:

This would indicate that your program stoppd working. I would maybe look for one of the following:

1- is there one special case for which you might return an empty value? (Like a case for which your result strimng might remain empty or an object that could not get initialized in a very “unexpected circumstance”.
2- If you use array, are you sure there is absolutely no chance to index a value out of range?
3- If you use list, are you shure your predicate will always return a valid value? Even if the nodes numbers are not cunitnuous? Even if the nodes number are only negatives? Even if the node numbers are only positiove starting above 0?
4- This was the mistake I ran into: are you (very very) sure nothing is hardcoded? My first algorithm removed the node “0 1” when the virus was more than 1 node away from a gateway. This worked in the IDE, not in the validation. Do you have anything similar, like "remove the link [G G+1] where G id the adress of a gateway? If so, this is also some kind of hardcoding.

1 Like

Well :

1 - Nope
2 - Nope not out of range
3 - Using array
4 - I have an array grid of all connected nodes. If the agent is one node away from the gateway i close the path from the gateway to the agent and then remove it from the grid (since it’s no longer connected). I randomly close an gateway path If an agent is more than 2 spaces from a gateway. So yes i do have that but i do not see the point of this beeing wrong?

You can send me your code. I’ll try to help.

Salut,

j’ai passé tous les tests mais je n’arrive pas débloquer le trophée “Embuscade” alors qu’il me reste 53 liens. Bug ou pas ?

Vérifie qu’il te reste bien au moins 50 liens dans le dernier test de validation, celui dans l’IDE ne compte pas pour le trophée.

C’est bon j’ai amélioré mon code ça marche pour le trophée. Le jeu affichait bien 52 liens mais le code avait trop de failles

So, first I submitted a solution I did not think particularly hard about, and it got all 3 achievements.
After that I started to seriously ponder on a general approach that could solve any problem of that kind.

To my utter surprise, what I found out, is that there is no guaranteed working solution for the 3rd achievement if AI is smart enough.
There is no valid algorithm to save >= 50 links for all cases of AI behavior. The best working approach can save only 49 guaranteed.

I feel like I wasted my time trying to find a general solution when there is not any by the very design of the 4th test.

The best “working” solutions proposed here are mere heuristics that work only for a particular behavior of AI in two particular tests. So, all the “valid” solutions for the 3rd achievement are hard-coded by definition.
What a bummer! :frowning:

The test n°4 is not the same in the IDE and the validator, I had to optimize the links to destroy to get the “ambush” reward…

1 Like

There is something I don’t understand. The input seems like at bottom in testcases. And when I use it in custom test case and run it works. But when I use the input in my desktop IDE it does not work (obviously). That does not seem like a valid input. How does it work in browser IDE?

DUMB 3 117 257 356 120 623 257 2 1 2 1 0 1 1 2

Okay. Answering my own question in case someone else is wondering. I think the inputs are for the browser player to read and not for the solution we write. First batch is number of nodes and their coordinates in the player. Second batch is links. After the links is the initial position of virus. After that comes number of gateways in one line and their indices in next lines.

Deleted ,

Hi, I already resolved the puzzle, but I am currently improving my code in order to get the third achievement.
I have some new code I want to test, that passes all the three first test cases, but fails with the fourth (Triple Star) with this error when I play it in IDE, but not in Visual Studio 2013 :
Warning: Degraded allocation. Consider increasing nursery-size if the warning persists.
Stack overflow: IP: 0x5e5d8f, fault addr: 0x7ffd76205ff8
Stacktrace:
at <0xffffffff>
at (wrapper alloc) object.Alloc (intptr) <IL 0x0004f, 0xffffffff>
<…>
at System.Collections.Generic.List`1.System.Collections.Generic.IEnumerable.GetEnumerator () <IL 0x00006, 0x0002f>
The stack trace gives me a method that is recursively called.
Do you guys already had this kind of error in IDE and not in Visual Studio ?
What can I do ?

Stack overflow is a typical indicator that your recursivity is going too deep.
Maybe CG has tighter constraints than your system on this.

The workaround is to flatten your recursive code (or at least some of it) into in-function loops.

1 Like

Thanks for your answer. I was afraid of that (having to flatten the recursion), according to what I found about this error.
I just wonder why it seems to be not so much known that recursion is almost unusable on CodinGame. I must not be the first to use recursion in my code…

1 Like

Hi ! :slightly_smiling:

I pass all tests but my code fail on the last validation test for no reason (i don’t let skynet win)
What can i do ?
@FredTreg @Djoums ? :slightly_smiling:

Hard to tell without any further information.
Check your replay on the last submission test. If the virus wins then you don’t handle it well enough. If not, your code is either too slow (timeout) or throws an exception somewhere, which makes you insta-lose.

this code passes all tests but fail on last validation why ?

The hardcoding validation checks for the submission tests are pretty damn ruthless.

I used this puzzle as a means to improve on my OOP in C++. I created a Node and Arena Matrix class and mapped all the available nodes and their connections into objects. The code is probably a lot more complicated then it needed to be but it was an exercise in a method I wanted to experiment with more then anything.

I passed all the tests in the IDE but failed on the last two within the submission tests - for hardcoding ??? I can tell ya, nothing was hardcoded. All given parameters were stored in variables and all the node ids were stored in their relevant node objects with their child link maps. There are enough iterators and pointers in that code to make Bill Gates head spin.

Watching the replay, I saw that my code failed by performing steps which from what I understood about my code to be logically impossible. It was at that point I realised the checks were actually modifying my code at some point. It was the only explanation.

It took me a while to realise that the code being modified was in fact the ids for the nodes. They had to be stored so I could reference them as necessary and remove their links as they are broken but the validation checks were changing them or something and causing the code to fail.

In my mind, this validation test is BS. If you screw with a volatile logic system you can’t blame it for failing. No wonder it started making weird choices in those last two tests.

My solution was simple. Don’t store the node ids as you receive them. I stored their value as a power of and just sqrt it when I needed to use cout to break their links. That fact that even worked just shows how flawed the validation system is.

I understand the need to check for hardcoding and other means of cheating the validation checks, but when you start breaking valid code mechanisms in the process their is something seriously wrong. I can only imagine how many people gave up on this test or completely rewrote their code because of the over-zealous and intrusive validation checks.