I managed to follow along and added this to a game and it works, but is there a way to call a specific genome from the Neat class to draw to a frame? I tried creating a method in the Neat class that would use the getGenome method in the client class but it didn't seem to work
i think there isnt but if you want to extend the code, you could do the following: in the NEAT class write a getter for a client: public Client getClient(int index){ return clients.get(index); } (I am not sure if clients is an arraylist or just an array. I am not looking at my code rn). You could also get the best client: public Client getBestClient() { int index = 0; for(int i = 0; i < clients.size(); i++){ if(clients.get(index).getScore() < clients.get(i)){ index = i; } } return clients.get(index); } You can extract the genome of a client by calling getGenome() on the client. For example: Genome bestGenome = yourNeatObject.getBestClient().getGenome(); I was not looking at my code so there might be some variable names wrong here. Hope this helps
@@Sajal7861 Sure, here is a link to a zip folder containing the project. drive.google.com/open?id=1J6qDEl9RiS9ZS0yksQN6001zkvNp8eO_ It may be a little hard to follow since it definitely isn't the cleanest code I've written.
Akash Karnatak if I Remember correctly, the original paper wasn’t very precise here. I assumed that taking the average fitness of a species does the job but I might be wrong here. I forgot to implement a penality if a species gets to large. So yeah you can go ahead and implement this
If I were to implement this in a game how would you decide what output action to take from the array of output values returned by the call to client.calculate(inputs)
you could e.g. take the one with the highest value. Like you have 4 controls, you also have 4 output values and if e.g. output no1 has the highest value, you use control1
Excellent series! Kinda echoing Jean, it'd be awesome if you could make an example where you applied this to something, such as Snake or some other simple game, and showed the code of how you did that!
@Finn Eggers I finished my implementation of NEAT in javascript. I tried it on XOR problem but I am stuck with an average accuracy of 82% no matter how much I tweak the algorithm. Did you try your NEAT algorithm on XOR problem?
@@finneggers6612 Each element of this list [[0,0],[0,1],[1,0],[1,1]] is an input. So I choose a random element from this list and supply it as input. If I do this 100 times, 82 times I get the correct answer.
@@finneggers6612 I ran 150 genomes for 100 generations. The best network doesn't use any hidden nodes. It has 2 nodes for input, 1 bias node and 1 output node
Awesome work. After evolve, purging old links nodes not used by any gnome improves performance quite a lot
Why do you assigning zero to replacement index just right after getting a replacement index from neat? it's always zero in that case (0:40)
thanks a lot !
great series, could you make a video about a more complex example next time ?
continue like this !
I managed to follow along and added this to a game and it works, but is there a way to call a specific genome from the Neat class to draw to a frame? I tried creating a method in the Neat class that would use the getGenome method in the client class but it didn't seem to work
i think there isnt but if you want to extend the code, you could do the following:
in the NEAT class write a getter for a client:
public Client getClient(int index){
return clients.get(index);
}
(I am not sure if clients is an arraylist or just an array. I am not looking at my code rn).
You could also get the best client:
public Client getBestClient() {
int index = 0;
for(int i = 0; i < clients.size(); i++){
if(clients.get(index).getScore() < clients.get(i)){
index = i;
}
}
return clients.get(index);
}
You can extract the genome of a client by calling getGenome() on the client.
For example:
Genome bestGenome = yourNeatObject.getBestClient().getGenome();
I was not looking at my code so there might be some variable names wrong here. Hope this helps
I figured it out thanks! I was doing this but trying to call the genome from a class different from the one where I initiated the neat class
Would you mind sharing the project I would like to get an idea of how to implement it in one of my games. Thanks :)
@@Sajal7861 Sure, here is a link to a zip folder containing the project.
drive.google.com/open?id=1J6qDEl9RiS9ZS0yksQN6001zkvNp8eO_
It may be a little hard to follow since it definitely isn't the cleanest code I've written.
@@ryanhiggins8009 Awesome thanks so much man
I watched this playlist multiple times but I think you forgot to implement explicit fitness sharing .
Akash Karnatak if I Remember correctly, the original paper wasn’t very precise here. I assumed that taking the average fitness of a species does the job but I might be wrong here. I forgot to implement a penality if a species gets to large. So yeah you can go ahead and implement this
@@finneggers6612 Got it. thanks for the reply.
If I were to implement this in a game how would you decide what output action to take from the array of output values returned by the call to client.calculate(inputs)
you could e.g. take the one with the highest value. Like you have 4 controls, you also have 4 output values and if e.g. output no1 has the highest value, you use control1
Excellent series!
Kinda echoing Jean, it'd be awesome if you could make an example where you applied this to something, such as Snake or some other simple game, and showed the code of how you did that!
yeah i might look into that.
@@finneggers6612 Yay!
@Finn Eggers I finished my implementation of NEAT in javascript. I tried it on XOR problem but I am stuck with an average accuracy of 82% no matter how much I tweak the algorithm.
Did you try your NEAT algorithm on XOR problem?
Akash Karnatak how would you possibly reach 82%? Like 50% or 25% would make sense. What exactly have you tried?
@@finneggers6612 Each element of this list [[0,0],[0,1],[1,0],[1,1]] is an input. So I choose a random element from this list and supply it as input. If I do this 100 times, 82 times I get the correct answer.
Akash Karnatak well just do it 4 times. Once for each input and you will probably get 75%
What is your network size?
@@finneggers6612 I ran 150 genomes for 100 generations. The best network doesn't use any hidden nodes. It has 2 nodes for input, 1 bias node and 1 output node