def add(vec0, vec1): """Adds two vectors.""" x0, y0 = vec0 x1, y1 = vec1 return (x0 + x1, y0 + y1) def get_occupant(game, position): """Returns the agent at position, if there is one.""" positions_with_agents = game.get_agents_by_position() if position in positions_with_agents: agents_at_position = positions_with_agents[position] return agents_at_position[0] def distance(vec0, vec1): """Returns the Manhattan distance between two positions.""" x0, y0 = vec0 x1, y1 = vec1 return abs(x1 - x0) + abs(y1 - y0)