-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsecond.py
More file actions
27 lines (22 loc) · 746 Bytes
/
second.py
File metadata and controls
27 lines (22 loc) · 746 Bytes
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
from vector import Vector
class Vehicle:
def __init__(self,n,x,y):
brain = Perceptron(n,0.001)
self.location = Vector([x,y])
self.velocity = Vector([0,0])
self.acceleration = Vector([0,0])
self.maxforce = 0.1
self.maxspeed = 4
def update():
self.velocity.add(self.acceleration)
self.velocity.limit(self.maxspeed)
self.location.add(self.velocity)
self.acceleration.mult(0)
def applyForce(self, force):
acceleration.add(force)
#expects an array
def steer(self, targets):
if isinstance(targets,Vector):
forces =
elif isinstance(targets,[]):
targets = Vector(targets)