Python 3 - 1.1.6 starter kit bug


#1

I downloaded 1.1.6 starter kit for WIN X64. When I run starter bot i get:

[info] Map seed is 1544555113
[info] [P0] Launching with command python MyBot.py
[info] [P1] Launching with command python MyBot.py
[info] [P0] Initializing player
[info] [P1] Initializing player
[info] [P0] Initialized player Traceback (most recent call la
[info] [P1] Initialized player Traceback (most recent call la
[info] Player initialization complete
[error] [1] [P0] Communication failed
[error] [1] [P1] Communication failed
[error] [1] [P0] Last input received was:
[error] [1] [P0]   File "MyBot.py", line 23, in <module>
[error] [1] [P0]     game = hlt.Game()
[error] [1] [P0]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\networking.py", line 35, in __init__
[error] [1] [P0]     self.players[player] = Player._generate()
[error] [1] [P0]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\player.py", line 64, in _generate
[error] [1] [P0]     return Player(player, Shipyard(player, -1, Position(shipyard_x, shipyard_y)))
[error] [1] [P0]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\positionals.py", line 70, in __init__
[error] [1] [P0]     self.normalize()
[error] [1] [P0]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\positionals.py", line 73, in normalize
[error] [1] [P0]     self.x = self.x % constants.WIDTH
[error] [1] [P0] AttributeError: module 'hlt.constants' has no attribute 'WIDTH'
[error] [1] [P1] Last input received was:
[error] [1] [P1]   File "MyBot.py", line 23, in <module>
[error] [1] [P1]     game = hlt.Game()
[error] [1] [P1]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\networking.py", line 35, in __init__
[error] [1] [P1]     self.players[player] = Player._generate()
[error] [1] [P1]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\player.py", line 64, in _generate
[error] [1] [P1]     return Player(player, Shipyard(player, -1, Position(shipyard_x, shipyard_y)))
[error] [1] [P1]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\positionals.py", line 70, in __init__
[error] [1] [P1]     self.normalize()
[error] [1] [P1]   File "D:\python_programming\Halite3_Python3_Windows-AMD64_1_1_6\hlt\positionals.py", line 73, in normalize
[error] [1] [P1]     self.x = self.x % constants.WIDTH
[error] [1] [P1] AttributeError: module 'hlt.constants' has no attribute 'WIDTH'
[warn] [1] [P0] Killing player
[warn] [1] [P1] Killing player
[info] [1] [P0] player has insufficient resources to continue
[info] [1] [P1] player has insufficient resources to continue
[info] [1] Game has ended

Someone has an idea what’s wrong?

EDIT:
From what I understand starter code is trying to do “time travel” and during player initialization use constants that are set later during game map initialization. Am I correct?


#2

Yeah.

For now, you can get around this by editing normalize() in positionals.py to make it something like this:

    def normalize(self):
        try:
            self.x = self.x % constants.WIDTH
            self.y = self.y % constants.HEIGHT
        except:
            pass

#3

Hi @planczl, sorry for the trouble - a fix will be coming in https://github.com/HaliteChallenge/Halite-III/pull/181.


#4

Fix rolling out, please see [PSA] Re-download Python starter kit if you started between 12/10 and 12/11.


#5

Thanks for quick fix.
I re-downloaded starter kit and starter bot works. But when I moved “hlt” catalogue to my bot the behaviour is strange. It does not crash but stops working as intended. I have to look into it in details but I would like to know if something major changed so I can focus on it. I compared files from both 1.1.6 and 1.1.5 starter and I don’t find anything that from quick check could break it - but it still does.
It’s not a big deal because with 1.1.5 “hlt” catalogue everything works fine. It’s just curiosity.


#6

Hmm, perhaps changing how ship objects were hashed/compared is changing iteration order in a dictionary, or causing ships to overwrite each other (two ship objects with the same owner/ID are now considered equal, even if they’re different objects).


#7

I was able to run my bot with 1.1.6 starter “hlt” catalogue with simple modification:

One is adding normalize=False in directional offset:

def directional_offset(self, direction):
    """
    Returns the position considering a Direction cardinal tuple
    :param direction: the direction cardinal tuple
    :return: a new position moved in that direction
    """
    return self + Position(*direction, normalize=False)

From my point of view this should be included in starter kit because normalizing direction changes “-1” values in North and West and you get wrong values of directional offset.

Second was adding normalize=False in definitions of __add__ and __sub__ for positions. I don’t know yet why it helped, but I will try to find out when I have more time.

EDIT: added strikethrough - see post below


#8

It’s not that at all. You get good results. It’s my mistake.
This is what you get when you don’t check your assumptions :slight_smile:

Still without adding normalize=False in __add__ and __sub__ my bot stops working. I don’t know why. It might be some error in my code.