Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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'
Esempio n. 4
0
 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'
Esempio n. 5
0
 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)
Esempio n. 6
0
 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'
Esempio n. 7
0
 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'
Esempio n. 8
0
 def _release(self):
     for action in ['LEFT', 'RIGHT', 'HIGH_KICK']:
         keys.release_key(self._key_bindings[action])
Esempio n. 9
0
 def _stop_defence(self):
     keys.release_key(self._key_bindings['LEFT'])
     keys.release_key(self._key_bindings['UP'])
     time.sleep(0.1)
Esempio n. 10
0
 def _stop_attack(self):
     keys.release_key(self._key_bindings['HIGH_PUNCH'])
     keys.release_key(self._key_bindings['RIGHT'])
     time.sleep(0.1)
Esempio n. 11
0
 def move(self, direction):
     press_key(self._keybindings[direction])
     time.sleep(0.05)
     release_key(self._keybindings[direction])
     time.sleep(0.05)
Esempio n. 12
0
 def start(self):
     press_key(self._keybindings['START'])
     time.sleep(0.05)
     release_key(self._keybindings['START'])
     time.sleep(0.05)
Esempio n. 13
0
 def select(self):
     press_key(self._keybindings['BLOCK'])
     time.sleep(0.05)
     release_key(self._keybindings['BLOCK'])
     time.sleep(0.05)
Esempio n. 14
0
 def _release(self):
     for action in ['UP', 'LEFT', 'RIGHT', 'HIGH_PUNCH']:
         keys.release_key(self._key_bindings[action])
Esempio n. 15
0
 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'