-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoDI_battle.py
39 lines (37 loc) · 1.2 KB
/
RoDI_battle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import rodi #Para exportar la biblioteca de codigos de rodi
import time #Para exportar la biblioteca de tiempos
robot = rodi.RoDI()
import random
try: #Intentar algo
robot.move_left()
time.sleep(1)
while True:
x= random.randrange(255)
a= random.randrange(255)
c= random.randrange(255)
linea = robot.sense()
print(linea[0])
print(linea[1])
if ((linea[0]) < 200 and (linea[1]) < 200):
if robot.see() <= 3:
robot.move_forward()
robot.move(-50,-50)
time.sleep(0.2)
robot.move_forward()
robot.pixel(100,0,0)
elif robot.see() < 20 and robot.see() > 3:
robot.move(50,50)
robot.pixel(100,50,0)
time.sleep(0.01)
elif ((linea[0]) > 200 and (linea[1]) > 200):
robot.move_stop()
time.sleep(0.5)
robot.move_backward()
time.sleep(0.5)
robot.move(-20,50)
robot.pixel(x,a,c)
time.sleep(0.01)
except KeyboardInterrupt: #excepto cuando hay una interrupcion por teclado
print("Finalizado")
robot.pixel(0,0,0)
robot.move_stop()