def _random_attack(self): attack = self._key_bindings[random.choice(attacks)] self._memory.append(attack) keys.press_key(attack) time.sleep(0.05) keys.release_key(attack) time.sleep(0.05)
def _random_move(self): move = self._key_bindings[random.choice(moves)] self._memory.append(move) keys.press_key(move) time.sleep(0.05) keys.release_key(move) time.sleep(0.05)
def press_moves_concurrent(self, moves, sleep_time): for move in moves: keys.press_key(self._key_bindings[move]) time.sleep(sleep_time) for move in moves: keys.release_key(self._key_bindings[move]) return moves, 'concurrent'
def _attack(self): if self._current_action == 'defence': self._stop_defence() keys.release_key(self._key_bindings['HIGH_PUNCH']) time.sleep(0.05) keys.press_key(self._key_bindings['HIGH_PUNCH']) keys.press_key(self._key_bindings['RIGHT']) self._current_action = 'attack'
def _random_good_move(self): if not self._good_moves: return seq = random.choice(self._good_moves) for action in seq: self._memory.append(action) keys.press_key(action) time.sleep(0.05) keys.release_key(action) time.sleep(0.05)
def _defence(self): keys.press_key(self._key_bindings['LEFT']) time.sleep(0.05) keys.release_key(self._key_bindings['LEFT']) time.sleep(0.05) keys.press_key(self._key_bindings['LEFT']) time.sleep(0.05) keys.release_key(self._key_bindings['LEFT']) time.sleep(0.05) keys.release_key(self._key_bindings['HIGH_KICK']) time.sleep(0.05) keys.press_key(self._key_bindings['HIGH_KICK']) self._current_action = 'defence'
def _attack(self): keys.press_key(self._key_bindings['RIGHT']) time.sleep(0.05) keys.release_key(self._key_bindings['RIGHT']) time.sleep(0.05) keys.press_key(self._key_bindings['RIGHT']) time.sleep(0.05) keys.release_key(self._key_bindings['RIGHT']) time.sleep(0.05) keys.release_key(self._key_bindings['HIGH_KICK']) time.sleep(0.05) keys.press_key(self._key_bindings['HIGH_KICK']) self._current_action = 'attack'
def move(self, direction): press_key(self._keybindings[direction]) time.sleep(0.05) release_key(self._keybindings[direction]) time.sleep(0.05)
def start(self): press_key(self._keybindings['START']) time.sleep(0.05) release_key(self._keybindings['START']) time.sleep(0.05)
def select(self): press_key(self._keybindings['BLOCK']) time.sleep(0.05) release_key(self._keybindings['BLOCK']) time.sleep(0.05)
def _random_movement(self): movement = self._key_bindings[random.choice(['LEFT', 'RIGHT'])] self._memory.append(movement) keys.press_key(movement) time.sleep(0.25)
def _defence(self): if self._current_action == 'attack': self._stop_attack() keys.press_key(self._key_bindings['LEFT']) keys.press_key(self._key_bindings['UP']) self._current_action = 'defence'
def press_moves_sequence(self, moves, sleep_time): for move in moves: keys.press_key(self._key_bindings[move]) time.sleep(sleep_time) keys.release_key(self._key_bindings[move]) return moves, 'sequence'