[SOLVED]Directional_offset() in Python


#1

Hi everyone!
When I trying to do :

new_point = pos.directional_offset((1,0))
if game_map[new_point].is_empty and game_map[new_point] not in eng:

Error is returned

if game_map[new_point].is_empty and game_map[new_point] not in eng:
File “/home/worker/Halite/apiserver/worker/tmpghj2z983/4904_editor_my-bot/hlt/game_map.py”, line 126, in eq
return self.position == other.position
AttributeError: ‘Position’ object has no attribute ‘position’

Need your help.


#2

game_map[new_point] not in eng
This is the source of the error. It calls __eq__ method with each element of the sequence (if this elements do not have __hash__ method). Your list (set, whatever) contains Position instances, not MapCells. But game_map[new_point] is instance of the MapCell. So change it to game_map[new_point].position not in eng.


#3

Thank you so much! It really helped.