49 lines
957 B
Python
Executable File
49 lines
957 B
Python
Executable File
#!/usr/bin/env python
|
|
import math
|
|
import pygame
|
|
import random
|
|
|
|
from car import Car
|
|
from maps import map1
|
|
from params import CELL_COLOR, screen
|
|
|
|
|
|
#https://medium.com/intel-student-ambassadors/demystifying-genetic-algorithms-to-enhance-neural-networks-cde902384b6e
|
|
|
|
|
|
map_lines = map1
|
|
|
|
|
|
|
|
all_cars = pygame.sprite.Group()
|
|
|
|
for x in range(100):
|
|
car = Car()
|
|
car.heading = x * 30 + 35
|
|
all_cars.add(car)
|
|
|
|
clock = pygame.time.Clock()
|
|
running_cars = True
|
|
while running_cars :
|
|
running_cars = False
|
|
screen.fill(CELL_COLOR)
|
|
all_cars.draw(screen)
|
|
for c in all_cars :
|
|
c.show_features()
|
|
if c.run :
|
|
running_cars = True
|
|
c.probe_lines_proximity(map_lines)
|
|
c.probe_brain()
|
|
c.update()
|
|
|
|
for line in map_lines :
|
|
pygame.draw.line(screen, (255,255,255), line[0], line[1])
|
|
|
|
|
|
pygame.display.flip()
|
|
clock.tick(24)
|
|
|
|
while True :
|
|
pygame.display.flip()
|
|
clock.tick(24)
|