Esempio n. 1
0
    def __init__(self, windowWidth, windowHeight):
        self.brain = Brain(1000)

        # Starting location at the bottom center with no velocity or acceleration
        self.pos = Position(windowWidth // 2, windowHeight - 10)
        self.vel = Position(0, 0)
        self.acc = Position(0, 0)

        self.dead = False
        self.reachedGoal = False
        self.isBest = False

        self.fitness = 0
Esempio n. 2
0
def main():
    fps_lim = 60
    running = True

    width = 800
    height = 800

    # Assigning the coordinates of the goal 10% from the top and halfway horizontally
    goal = Position(width // 2, int(height * 0.1))

    # Setup pygame initialisation parameters
    pygame.init()
    pygame.display.set_caption("Dot Genetic Algorithm")

    screen = pygame.display.set_mode((width, height))
    screen.fill((255, 255, 255))

    clock = pygame.time.Clock()

    d = Dot()
    # print(d.brain.directions)
    d.brain.mutate()
    # print(d.brain.directions)

    while (running):
        clock.tick(fps_lim)

        pygame.display.flip()

        # Draw goal
        pygame.draw.circle(screen, RED, (goal.x, goal.y), 8)

        # Draw obstacle

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
import csv

for row in csv.reader(open("test.csv")):
    print row[0], ":".join(row[1:4]), ":".join(row[4:])
    

from coords import Position
for row in csv.reader(open("test.csv")):
    p = Position("%s %s" % (":".join(row[1:4]), ":".join(row[4:])))
    print row[0], p.galactic()