def __init__(self, point, radius, circle_width, num_sensors, sensor_range, velocity, sensor_width): self.x = point.x self.y = point.y self.radius = radius self.circle_width = circle_width self.num_sensors = num_sensors self.sensor_range = sensor_range self.sensor_width = sensor_width self.velocity = velocity self.sensors = [] self.prev_x = self.x self.prev_y = self.y # Nik's attributes self.prev_theta = 0 self.width = self.radius * 2 self.velocity = velocity self.velMax = 8 self.velMin = -8 self.acc = 0.1 self.omega = 0 self.omega_acc = 0.0174533 self.R = 0 self.theta = 0 self.dt = 1 self.font = pygame.font.SysFont('comicsans', 16, False, False) self.center = pnt(self.x, self.y) self.circle = self.center.buffer(self.radius).boundary self.angleDeg = 0 self.collision = False
def __init__(self, point, radius, circle_width, num_sensors, sensor_range, velocity, sensor_width, hidden_neurons): self.x = point.x self.y = point.y self.radius = radius self.circle_width = circle_width self.num_sensors = num_sensors self.sensor_range = sensor_range self.sensor_width = sensor_width self.velocity = velocity self.sensors = [] self.prev_x = self.x self.prev_y = self.y # Nik's attributes self.prev_theta = 0 self.width = self.radius * 2 self.velR = 0 self.velL = 0 self.velMax = 8 self.velMin = -8 self.acc = 0.1 self.iccX = 0 self.iccY = 0 self.omega = 0 self.R = 0 self.theta = 0 self.dt = 1 self.font = pygame.font.SysFont('comicsans', 16, False, False) self.center = pnt(self.x, self.y) self.circle = self.center.buffer(self.radius).boundary self.angleDeg = 0 self.collision = False self.collisionScore = 0 self.velocityScore = 0 self.fitnessScore = 0 self.fitnessScorePrevious = 0 self.dustEaten = 0 self.prev_DustEaten = 0 self.time = 0 self.terminateTimer = 0 self.terminateLimit = 200 self.collisionLimit = 50 # Neural Network # self.NN = NeuralNetwork(12, 2, 12) self.NN = RecurrentNeuralNetwork(12, 2, hidden_neurons)
def imminent_collision(self, wall): self.center = pnt(self.x, self.y) self.circle = self.center.buffer(self.radius).boundary collision = self.circle.intersection(wall.bound) return collision