all 14 comments

[–]magnora7[S] 4 insightful - 2 fun4 insightful - 1 fun5 insightful - 2 fun -  (0 children)

This is a simulation game, I made it mostly for myself to explore artificial intelligence and neural networks so it's not incredibly polished or user-friendly. But it is very interesting from a technological perspective. It's entirely html5 and javascript, and open source. You can right-click and 'inspect' to see all the code right in the file.

HOW TO PLAY: Each fish has a neural network of 12 neurons. Those neurons are connected to each other in random ways with random strengths. So all the fish have random brains at the start, and thus random behaviors. Each fish is unique.

Then a generation happens over a few seconds, the fish run their neural network programs. Each fish has inputs of knowing the angle of the nearest food and that food's color. It has outputs of what speed it swims and how much to turn. Each fish has a unique neural network, and every generation has 100 fish.

The 10 fish that are the best at eating food by the end of the round go on to create the "children" for the next generation. This mimics natural selection. The children are mixtures of the genes of the adults, plus some random noise. This mimics evolution.

The green food is worth is +1 point to the fish health, yellow is +3, and red is -1. The healthiest 10 fish at the end of the generation have the children for the next generation, as ranked by these scores.

This process then repeats again and again, generation after generation, and the neural nets get better at the task given their inputs and outputs, through the process of natural selection and evolution. The connection strengths between the virtual neurons find an arrangement that produces the selected-for behavior.

If you want to see this in fast-time, toggle with the letter 'F' and it will do the generations very quickly and graph them for you. The green line is the median health score of a fish for each generation. The yellow line is the top 25%, and the red is the top 10% (the ones that will make the children for the next generation). The zig zag lines show every generation and the straight lines are the average across the last 10. This shows you the total improvement, regardless of season. The zig-zag lines go away after generation 200 to just leave you with the averages.

The black line that goes down is the genetic diversity. When it starts, all the brains are random, so the genetic diversity is very high. As the system hones in on a good design, the genetic diversity of the population shrinks, which in turn shrinks the possible genetic diversity of the children. The genes determine the brain design, more specifically how strongly each neuron in the neural network is connected to every other neuron.

If the diversity gets too narrow, it can get "stuck" on a certain gene arrangement. Sometimes this is good to lock in on a really nice behavior, but sometimes it's not. If it gets stuck on a bad behavior you can increase the gene mutation rate (like radiation) by hitting 'P' or reduce it by hitting 'O'. This value is called "User added std" (standard deviation). This means you're adding more noise to the children's genes. If you add too much noise all the brains eventually go back to completely random after a few generations, but if you have too little then it might "lock in" too early and not have the opportunity to discover new gene patterns that might be even more efficient at eating food.

You can let it run as long as you want, and it'll go as fast as your processor can handle. If you watch the fish after evolving them for 15 minutes, you can see they're quite good at the task! After a few hours (if you have a good run), I don't think I could actually program them to do it more efficiently than they do it. It's kind of amazing and showcases how powerful neural network evolution can be.

When you restart the game by refreshing the tab, it'll start with an entirely new pool of random brains, so each evolution is completely different and the fish discover different strategies.

Also there is a "seasonal" cycle that repeats every 10 generations. During "summer" there is a lot of yellow and green food and very little red food. During "winter" it's mostly red food to be avoided with very little green. This diversity of food situations creates more robust fish behavior, that is good both at finding the yellow/green and avoiding the red.

Anyway, if you have questions let me know. I might develop this more if people are interested, but I thought you all might enjoy a chance to play with your own neural network and to try evolving things from scratch using neural network technology right in javascript and html5.


tl;dr: "O" creates less genetic diversity in future generations, "P" makes more, "F" goes fast with graphs that hopefully go up. The fish get really good at eating the food and they learn how all by themselves without being programmed. You can open multiple tabs and have them compete and compare how they evolve differently.

[–][deleted] 4 insightful - 2 fun4 insightful - 1 fun5 insightful - 2 fun -  (5 children)

Very nice.

[–]magnora7[S] 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (4 children)

Thanks, it's based off of a phd project I found online. I changed the javascript and html quite a bit, but it's really a short program when you consider all that it does. Maybe 2k lines total for everything.

[–][deleted] 3 insightful - 3 fun3 insightful - 2 fun4 insightful - 3 fun -  (3 children)

Yeah this emergent behavior stuff is fascinating. I like watching the dumb bastard fish swim in circles before they get smart.

[–]magnora7[S] 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (2 children)

Haha yeah there are some really dumb ones in the beginning. Sometimes they lean toward the "avoid the red" strategy and sometimes they lean more toward the "get the green/yellow" strategy. Sometimes you'll get a genius population that's good at both, but you have to get lucky to discover the right gene settings, since it's basically a smart random-walk function. But I guess real evolution is too. It's super fascinating.

[–][deleted] 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (1 child)

This is really impressive considering the lines of code. I like the 'F' interface too. And my fish swim way faster on desktop. Also my kid says "that's amazing" and "how cute".

So is the skipping/redrawing I'm seeing happen for each new generation? It's distracting but maybe it needs to be there.

[–]magnora7[S] 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (0 children)

I'm glad you and your kid like it! haha

So is the skipping/redrawing I'm seeing happen for each new generation?

Yup that's exactly right. It's resetting the food to new random positions, creating all the new fish for the next generation, then placing them.

I can make the generations longer, which is more fun to watch, but it takes longer for the intelligence to evolve because each generation is longer. Maybe I could make that a variable you could change on the intro screen if I made such a thing. There's like 20 variables to mess with at the start

[–]Marginotions 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (6 children)

Hi, chief. I have not investigated the game, but want to offer a suggestion. As you can see, this is not a well-occupied sub. My suggestion is that you save this post, with its comments, do whatever it takes to change the sub name to "s/evolutionpub" and post this item as first entry. We need to be able to have "sticky" or "announcement" posts to occupy top line of sub display. Is that already a thing in saidit?

I have many articles to post with evolution the feature theme, and of course there is the controversy between the scientific-cultural paradigms and the religious "creative intelligence" paradigm. I believe "s/evolutionpub" would be much more popular than the Fish Game, which maybe should be posted in a gaming sub anyway. (s/evolution is set to private? why?)

[–]magnora7[S] 3 insightful - 3 fun3 insightful - 2 fun4 insightful - 3 fun -  (5 children)

Thanks, I just wanted to share a project, I never really meant for this thing to grow.

It's called that because it's based around fishes that evolve. You should try it.

I was actually just building an update to their neural networks a couple days ago, I re-wrote the brains from scratch with a new architecture that works even better than the typical layered feed-forward ANN brain design used in most neural nets.

Also I made s/evolution public again, I don't know why that mod did that. Probably maliciously to keep people from using it.

[–]Marginotions 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (4 children)

Thnx mch, 'magnum' (lol). Will try the fish game later. You do neural nets? Awesome.

If you need a mod for s/evolution, I'm game for it. I have subs on reddit as mod u/acloudrift. You may remember me from years ago on CST. I quit there it was too corrupted by Lefties, but has great mods. I started up r/AlternativeHypothesis with CST as model, but shifted Right.

[–]magnora7[S] 2 insightful - 3 fun2 insightful - 2 fun3 insightful - 3 fun -  (3 children)

Ah cool. Yeah the fish evolution game is all about evolving neural nets. You can hit 'f' and it will go in to fast mode and you can see graphs of it improving. And then hit 'f' to turn off fast mode and go back in to viewing mode. That's the most important button.

If we need a mod there, I will be sure to contact you. Thanks for offering.

[–]Marginotions 2 insightful - 2 fun2 insightful - 1 fun3 insightful - 2 fun -  (2 children)

Hi magnanimousman, I tried to check the game today, Sep.1, link goes to page not found but we are blessed with saidit's beautiful image of road in forest https://saidit.net/static/reddit404e.png

I just checked also s/evolution, found it empty, began putting some stuffing into it. Was going to xpost a link to fishevolution, but oops, not there.

[–]magnora7[S] 2 insightful - 3 fun2 insightful - 2 fun3 insightful - 3 fun -  (1 child)

Ah I'll try putting the new version on sometime, I'm actually playing it right now. I remade their brains so they not only have neural nets, but actually program themselves with programming functions and variables

[–]Marginotions 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (0 children)

Kool. I'm jazzed about trying it. These cyberfish seem to be like cultures containing software engineers and web developers.