Honestly, I have no clue what happened. I was working on a different part of the code (towards the end of the file) when suddently during a test (which I run often), I get a timeout (failed to provide output in time). With some debugging, I managed to figure out the line that timed out. It was the input line that is already provided by default… I checked using the python time module to see if I actually ran out of time but right before the input I’m at 3ms out of 50… Here’s the part:
for i in range(num_units):
# unit_type: -1 = QUEEN, 0 = KNIGHT, 1 = ARCHER
x, y, owner, unit_type, health = [int(j) for j in input().split()] # Thats the line
if unit_type == -1 and owner == 0:
queen = Unit(x, y, owner, unit_type, health)
else:
units.append(Unit(x, y, owner, unit_type, health))
It actually goes through the loop just fine on the first time (to find my queen) but fails on the second looping. This happens on the first turn, so there are only 2 queens as units, but what happens to the other queen? It works fine on mine but not the other…