forked from tdostilio/Race_Game
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBrain.py
71 lines (52 loc) · 1.82 KB
/
Brain.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import time
import pygame
class Brain:
def __init__(self, database):
self.database = database
def run(self):
while True:
if self.database.stop:
break
time.sleep(0.001)
_ = pygame.event.get()
'''
DO NOT CHANGE CODE ABOVE!!!!
1. How can i get a lidar data?
data = self.database.lidar.data
2. How can i move a car?
self.database.control.up()
self.database.control.down()
self.database.control.right()
self.database.control.left()
OR
self.up(num)
self.down(num)
self.right(num)
self.left(num)
☆☆☆☆☆ In one loop,
you can only change the speed up to 5 and the angle up to 8!!
3. How can i get a car status data?
self.database.car.direction
self.database.car.speed
4. How can i get a v2x data?
self.database.v2x_data
'''
# Implement Your Algorithm HERE!!
# EXAMPLE CODE1: 속도 2로 유지하면서 오른쪽으로 회전하기
self.right()
if self.database.car.speed <= 2:
self.up()
elif self.database.car.speed > 3:
self.down()
def up(self, num: int = 1):
for i in range(num):
self.database.control.up()
def down(self, num: int = 1):
for i in range(num):
self.database.control.down()
def right(self, num: int = 1):
for i in range(num):
self.database.control.right()
def left(self, num: int = 1):
for i in range(num):
self.database.control.left()