Scroll down to "Program Rules" for a more program-specific explanation, and please note that this project is not nearly complete! Conceptual Explanation: Aesthetically-icky beetles defined by simplistic artificial neural networks. The bugs you see in this program undergo evolution, albeit extremely simplified (they have around 5 neural connections, whereas their real-life counterparts have around 200,000). Artificial neural networks (or at least, how I've utilised them in this project) consist of an array of inputs and outputs (imagine two parallel columns of 10 nodes or so, with the left column nodes representing input variables or information, and the right column nodes representing potential outputs, like movement or turning). The first beetles are born with random input-output connections (a neural connection might be arbitrarily wired to connect [straight-ahead distance to next beetle] to [turn left]). As time (generations) goes on, beetles with more energy-expensive and unhelpful neural networks will die sooner than their more intuitively-wired buddies. This will prevent them from (asexual) reproduction (the only condition of which is surviving until a certain age) and passing down their comparatively flawed genes, resulting in buggy (pun not intended) natural selection. Variable Interpretation: The upper left-most number represents generations per second, which is proportional to frames per second; basically, the higher the number, the better your computer's handling the project. The next figure to the right represents the generation number. This will steadily increase over time. The next figure is the beetle population, and the right-most figure is the number of food. Program Rules: Beetles can either eat food or their beetle friends to gain energy, which is what they need to survive. They will be born with a certain amount of energy, and the rate at which this energy decreases per generation will increase as they age (e += -(√(a/4))/5). Moving or turning will cost them energy, as will (asexually) producing offspring. Baby beetles will have a small chance of mutation (condition of natural selection, and thus, evolution). This mutation could be a new neural connection, the deletion of a neural connection, the change of a neural connection's weight or threshold. The rays/lines you see on the program represent individual beetles' "vision". Only the rays of vision that they actually consider are drawn and calculated, hence why they sometimes look random. Note that rays of vision can be obstructed by food or other beetles. This means that they have registered this piece of information, processed it, and made a decision. Other: Some beetles won't move; this isn't a bug (you know what I mean), it's only because their conditions of movement cannot be met given their neural networks. Some beetles get stuck in the corners. Yes, this is a bug. Beetles tend to West-East migration and I have no idea why, but I'll figure it out. You can literally see how they begin pointing in any direction, but then all orient themselves to the East and just *run*! It looks so dumb oh my god. Once the generation number reaches a couple of hundreds, it all just freezes up. This will be a major pain to fix. Click "see inside"; just try to imagine my dread at sifting through code to find out the reason for this bug. Some Stuff I Want To Say: Two factors drove me to write this project; my interest in evolution, and my extreme procrastination. I have many times attempted to write an evolution simulator (here's an old, fundamentally-cool but simple one that I shared: [ but its usually been fruitless. But this time, it was different; I had so ridiculously much work to procrastinate, and nothing to procrastinate with. So I watched some lectures and explanations before getting confident enough to write my own interpretation over a weekend! All of the code in this project is my own, but some general and non-neural-network-specific parts of it (a modified Fisher-Yates array shuffle and a Bresenham-line algorithm) are interpretations of some theory. I know that this project is really lacking in some UI, and probably, actual functionality, but I just wanted to share this piece of work that I'm proud of, that I may not have the opportunity to work on again. Specifics: For those who are curious, the inputs the beetles have access to are: - A random float between 0.0 to 1.0. - An oscillator (sine function dependent on time). - Nearest border distance, which will hopefully encourage them to avoid borders for the comparative lack of resources found there. - How long it takes for a vision ray to reach food or another organism (with a maximum range of 4). Some of these inputs are arbitrarily wired to some outputs: - Turn left 90º. - Turn right 90º. - Move forward one tile. - Move backward one tile. - "Lunge"; move forward two tiles, consuming more energy.
A recent project (mid 2022)-but one that is just too undeveloped to be on my main. Unfortunately, it's too stuttery on Scratch to be able to be fully appreciated. So, I recommend running it on TurboWarp, here: [https://turbowarp.org/732282061/fullscreen].