def get_pos_with_gravity(self, pos: Tuple[int, int, int]) -> Tuple[int, int, int]: """ Donne la position si le pion tombait d'en haut jusqu'à ce qu'il rencontre sois le bas du plateau, soit un pion Args: pos: la position de départ Returns: la position tombee """ pos = pos[0], self.taille - 1, pos[2] pion_sous = self.get_pion(add_dir(pos, BAS)) while pos[1] > 0 and pion_sous is None: pos = add_dir(pos, BAS) pion_sous = self.get_pion(add_dir(pos, BAS)) return pos
def __iadd__(self, vect: Tuple[int, int, int]) -> 'Curseur': """ Déplace le curseur, la nouvelle pos devient pos+vect, élément par élément Args: vect: """ self.pos = add_dir(self.pos, vect) return self
def pos_xyz(self) -> Tuple[float, float, float]: # les axes x et z sont décidés par alpha et beta x = cos(self.alpha) * sin(self.beta) * self.rayon z = sin(self.alpha) * sin(self.beta) * self.rayon # beta est le seul paramètre de l'axe y y = cos(self.beta) * self.rayon return add_dir((x, y, z), self.target)
def valid_move(self, vect: Union[Tuple[int, int, int], 'Curseur']) -> bool: """ Checks if making this move will result in a valid position Args: vect: the move Returns: new position is valid """ # noinspection PyTypeChecker return self.valid_pos(add_dir(self, vect)) and not all(a == 0 for a in vect)
def __sum(self, pos: Tuple[int, int, int], axes: Tuple[int, int, int]) -> int: """ Args: pos: Starting pos axes: the movement vector Returns: the number of consecutive equal pieces starting from pos, and moving by axes each time """ if axes == (0, 0, 0): return 1 somme = 0 pion = self.get_pion(pos) while self.valid_pos(pos) and self.get_pion(pos) == pion: somme += 1 pos = add_dir(pos, axes) return somme
def __add__(self, pos: Tuple[int, int, int]) -> 'Curseur': return Curseur(self.pos_max, add_dir(self.pos, pos))