I can't get the NEAT algo. Need someone to take my simple game made for human and add NEAT to it using NEAT-python library.
Game - neural network must write a number that should be close to the randomly generated number in each round. Closer guess = better score and higher fitness. If you select randomly generated number you get punishment. Simple, right? But can't understand how to implement the NEAT.
Here in the code the smaller the number the better. Here is the code:
import os
import math
import sys
import neat
import random
#idea = closer user input to the random number the better;
#if input of the user is the number itself it is bad;
class Agent():
def __init__(self):
super().__init__()
self.my_fitness = 0
def input(self):
user_input = int(input())
if target_n[0] > user_input:
dif = target_n[0] - user_input
else:
dif = user_input - target_n[0]
self.my_fitness = self.my_fitness - dif
bro1 = Agent() #make Agent
def eval_genomes():
#main loop
run = True
while run == True:
#set up
global target_n
target_n = random.sample(range(1,100),1)
print(target_n,'is the target')
#input
bro1.input()
print()
print('new round')
print(bro1.my_fitness)
print()
eval_genomes() #run the loop
How to implement NEAT?