def __blockPass(self, kIndex): """ This function will take a keeper to block as a parameter. The keeper that this taker is trying to block should NOT have the ball. This function works by taking the position of the keeper with the ball, and the position of the keeper to block, and making the taker run to the midpoint of these 2 positions. In 3V2 keepaway, this function should be implemented by the taker farther from the ball. :param kIndex: the index of the keeper to take, sorted by distance. so kIndex = 1 means the keeper who is closest to the ball besides the keeper who has the ball. kIndex = 2 means the 2nd closest keeper, and so on. :type kIndex: integer :returns: nothing """ #kIndex is ordered based on who is the closest keeper keeperActual = sorted(self.keeperArray) #use the current keeper 0 position to block pass midPoint = kUtil.getMidPoint(keeperActual[0].get_noisy_pos(), keeperActual[kIndex].get_noisy_pos()) #use the predicted keeper 0 position to block pass #midPoint = kUtil.getMidPoint(self.onReceiveDecision[1], keeperActual[kIndex].noisy_pos) vector = kUtil.getVector(self.__noisy_pos, midPoint) minDist = min(self.maxPlayerSpeed, kUtil.getDist(self.__noisy_pos, midPoint)) self.worldRef.moveAttempt(self, (vector, minDist))
def blockPass(self, kIndex): #kIndex is ordered based on who is the closest keeper keeperActual = sorted(self.keeperArray) midPoint = kUtil.getMidPoint(keeperActual[0].noisy_pos, keeperActual[kIndex].noisy_pos) vector = kUtil.getVector(self.noisy_pos, midPoint) self.worldRef.moveAttempt(self, (vector, self.maxPlayerSpeed))