again“ (algorithms min-max, alfa-beta…) -1 1 1 1 1 -1 -1 My move towards MAX score My move towards MAX score Opponents move towards MIN score -1 0 1 Opponents move towards MIN score 1 0 0 0 0 -1 -1 1 1
Ok, computer, this is an „A“: Ok, computer, this is a „C“: Ok, computer, this is an „L“: Ok, human, I‘ll learn that! Input here: 40×40 (1600) binary values
5 6 7 8 9 Color red red blue green red yellow blue green green Node 1 2 3 4 5 6 7 8 9 Color blue green red yellow yellow yellow red red green Node 1 2 3 4 5 6 7 8 9 Color red red blue green red yellow red red green Node 1 2 3 4 5 6 7 8 9 Color red blue blue green red yellow red red green
10 NODES = 9 TARGET_FITNESS = 0 make_individual = lambda: [random.choice(COLORS) for _ in range(NODES)] population = [make_individual() for _ in range(INDIVIDUALS)] new_population = [None for _ in range(INDIVIDUALS)] generation = 0 while True: fitnesses = map(fitness_func, population) if max(fitnesses) == TARGET_FITNESS: break for i in range(INDIVIDUALS): mom, dad = pick_parents(population) split_point = random.randint(0, NODES - 1) new_population[i] = mutate(mom[:split_point] + dad[split_point:]) population = new_population generation += 1