Possible Code4Life Bug? (bug thread is closed)

Hello! Either this is a bug, or I need to learn more about python. :slight_smile:

I have a set of code that runs great, got me to silver league, but I wanted to keep optimizing. What I found was that when I made a seemingly innocuous change to my code from:

priorityScores[k] = float(sampleGroup[k].health)/float(sampleGroup[k].totalCost())

To:

priorityScores[k] = float(sampleGroup[k].health)/float(1)

then I would always lose on step 23 because I failed to produce any output. You can see the replay here:

My bot always grabs 3 samples and analyzes them as the starting move. That might explain why it is always step 23 that kills me.

On the off chance that my full code would help with this, here is the full code.

Works:

[Don’t share full code in the forum]

The change I made was to line 81. Please help!

Hello,

With your change, you have a infinite loop L.35 (‘while len(priorityScores.keys()) > 0:’).

I guess it’s not a bug in our side. :stuck_out_tongue:

Ok, good to know. Thanks for the response. Could you help me understand why this would create an infinite loop? The change I made was not in the loop you mentioned. As far as I can tell, the change in calculatePriorityScores would only change the values in the returned dictionary, it wouldn’t affect deleting from that dictionary later. Help a fellow?

Your change does impact the loop, since you changed the priorityScores.

You have Heath = -1 for undiagnosed sample,

Let’s have priorityScores = [20,-1,20],

First 2 rounds, you will delete maxPriorityScore=20; then priorityScores = [-1]

Then you will never fullfiled the if priorityScores[k] > maxPriorityScore: as 0 > -1, and thus never delete the last item, len(priorityScores.keys()) > 0, will loop forever.

2 Likes

Wow, ok, then, I appreciate you taking that time to help me understand!

Hi guys,

is this thread with last posting from February the “official” bug thread? I see more recent bug threads but they are closed.

My problem: When I have 2 samples diagnosed, it seems to me that the “system” executes a "CONNECT " at the diagnosis station so that one sample is stored in the cloud which is not triggered by my robot’s code.

See the replay here: https://www.codingame.com/replay/314298134

Many thanks for any help
Frank

You print “CONNECT 1” twice.
Make sure that you only print 1 command each turn.

1 Like

Many thanks for the quick response.

But actually I don’t print CONNECT 1 twice: In my code I have a System.err.printlin() with the name of the method which is logged whenever I print a CONNECT x. I see this method name everyhwere where I expect a CONNECT x, but I see the a CONNECT x in the logging where this System.err.println() is not logged - this is why I think that the wrong CONNECT x is not from my code (however this may happen ?)

Now I get your point: I repeat the CONNECT in the while loop for the 2nd sample, which is wrong, because this 2nd CONNECT must wait for the next turn. I have corrected this, now it works perfect.

Thanks again for the quick help.

Looking at the referee code on GitHub, there is still one sample in the list that breaks symmetry, as noted a long time ago by Counterbalance in the original bug thread: Code4Life - Bugs
The offending sample is samplePool.get(1).add(new Sample(new int[] { 0, 2, 3, 0, 3 }, 20, MoleculeType.B));, which should be 10, not 20, to complete the symmetry. Symmetry would be nice!

Hello,

In the wood 2 league of this challenge, I am seeing a lot of timeouts, either from my code, from the opponent code and from both simultaneously.
See this https://www.codingame.com/replay/401807396
and this https://www.codingame.com/replay/401807472

And when such a timeout occurs, not even the very first command of the program, being a simple “print hello” is displayed in the game output.

Is there something wrong that I do?

Please see [java] random "Error occurred during initialization of VM"

Nope, it does not seem to change anything for me. See this last game: https://www.codingame.com/share-replay/403431275
I did try to change my code to remove some operations that may have been previously CPU-intense, but it does not change.
I have transcoded my program to Python3 and did not face the issue.

Then it’s the same bug resurfaced ig

Ok then. Thanks for the suggestion and the help @BenjaminUrquhart.
I will follow the other topic, see if some updates are posted.

Hi. I have a very stange problem in my code.

Console.err.println("Id: " + molList.head.sampleId.toString)
println("CONNECT " + molList.head.sampleId.toString)

But output is this:

Standard Error Stream:

Id: 1

Standard Output Stream:

CONNECT 0

How is this even possible? Am I missing something?

You sent multiple commands during one turn making the console desynchronize the error and output stream.

1 Like