Pixi - Evolution Simulator [WIP]

Show off your games, demos and other (playable) creations.
User avatar
ImpTea
Prole
Posts: 7
Joined: Sat Mar 06, 2021 3:37 am

Pixi - Evolution Simulator [WIP]

Post by ImpTea »

Hello everyone! First time posting here!

For the last few weeks I've been working on this project. It is a "petri dish" style evolution simulator. I call the lifeforms "pixies" (singular: pixi) since their bodies are composed of pixels. The pixies start out with completely random brains and bodies - the vast majority don't make the cut. But the lucky few who are able to achieve replication rapidly begin adapting to the environment. They can reproduce sexually or asexually, with small random mutations occurring in their spawn.

A pixi's genome defines everything about it - it's size, shape, color, how its brain functions, and how it communicates with its fellow pixies. A pixi's body is generated using extremely complex mathematical functions that can produce practically infinite variety in structure. Its behavior is produced by a relatively simple matrix / network of sensory inputs which connect to each of its potential actions with varying weight, dependent on its genetic makeup. Though simple, their brains are refined through the pressures of natural selection to produced fairly sophisticated and highly efficient survival strategies.
Some random pixi bodies!
Some random pixi bodies!
pixiBodies.png (11.27 KiB) Viewed 5665 times
Let it run for long enough, and you'll observe the pixies' bodies become streamlined in alignment with their behavior. I find it fascinating when predator-prey relationships develop between species, or when a single species branches into subspecies with different tasks. I am continuing to look for ways to enrich the sandbox with a wider range of senses/actions to allow for more specialized pixi species to develop.

Pixies' bodies interact on a per-pixel basis. When pixies collide their overlapping pixels are destroyed; the pixi with the larger mass gains energy from the interaction. If a pixi contacts the 'heart' (lighter colored portion) of another pixi, it effectively eats it, absorbing its energy. Pixies may also choose to be peaceful - two peaceful pixies will not harm each other, but an aggressive pixi will destroy a peaceful pixi without taking damage.

You can save pixi genomes that you find interesting for whatever reason, and load them into the instance in real time. Feel free to share them here, I'd love to see what you uncover - I'm interested in accumulating a "library" of specialized pixies that can be thrown into the ring against each other. You can also play god by cross-breeding pixies to select for whatever traits you desire.
You can peak into their brains by selecting a pixi and scrolling over its "senses". Each sense is paired with a gene, and each 'nucleotide' on the gene determines how strongly that sense affects each action. Values less than 5.5 affect the action impulse negatively, while values greater than 5.5 affect it positively. If the action impulse (shown for each action) crosses a certain threshold, the pixi performs the action.

I am planning a larger write-up about how this all works, along with some screenshots and maybe videos. Eventually I'll get around to posting the source code. I am an amateur/hobbyist coder with no formal education, so I'm trying to learn how clean up my code for public consumption. I'm frankly embarrassed to post it, since I'm certain it's of such low quality. This is the biggest thing I've ever made, and my god it's 1400 lines in a single file >_<

In the meantime, please let me know what you think so far! I'd love to get some feedback on what direction I should take this project. Perhaps there are ways to "gamify" this project to make it more interesting for people to interact with. If you don't find evolution simulators inherently interesting, then... this is little more than an odd screen-saver haha.

Next steps:
--Give users ability to adjust settings such as food density, movement cost, breeding cost, mutation rates, max size, resolution, etc.
--Implement an actual GUI (ughh.....)
--Save/Load whole instances, not just individual pixis

EDIT: love file has been updated to latest version.
Attachments
Pixi.love
(13.66 KiB) Downloaded 223 times
Last edited by ImpTea on Sat Mar 13, 2021 1:04 am, edited 1 time in total.
User avatar
ImpTea
Prole
Posts: 7
Joined: Sat Mar 06, 2021 3:37 am

Re: Pixi Dish [WIP]

Post by ImpTea »

Since posting, I've made some changes worthy of an update. The graphics system was revamped to improve performance (I had no idea about ImageData, I was drawing the individual pixels with love.graphics.points!).
This also allowed me to implement a shader for the pixies' bodies to make them more interesting looking (todo: varying shaders/shader properties depending on pixi DNA?)
I also fixed some bugs, balanced the simulation, and added a nice "oomph" effect when pixies collide.

Download below!
Attachments
Pixi.love
(11.49 KiB) Downloaded 210 times
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: Pixi Dish [WIP]

Post by Gunroar:Cannon() »

I like the premise (I like things that run continuously regardless of the player). I haven't run it yet, but I'll give feedback when I have. You could gamify it by having the player choose some of the actions for a pixi they control, like attack a certain pixi and eat some things and stuff(indirect control like sims). Going further (with what I can think of now) you could make more behaviours for special pixi types(that are rare or something) that do things like explode and spawn other powerful pixies(Legendary Pokémon, boss monster type of thing).
You could befriend pixies by getting your pixi to do things for them, make a map of some kind(maybe progen or an island) and go to certain places where only certain type of pixis can be generated(due to their adaption, like a fire-covered :P pixi that lives in an ice cave and uses that to keep warm) and where you can collect items, you could also give them personality traits that make then react to different things with different traits in different ways( am I going to far? :P :ultrahappy: )
This seems more like a casual phone/pocket game I should be able to play anytime I get bored, and that it would have more popularity on mobile, but you never know.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Pixi Dish [WIP]

Post by milon »

This is really cool! I've only been running it for a few minutes, but I've got a pixi I'd like to share. I saved to to a slot in-app. How/where do I find its data to upload? (EDIT: https://love2d.org/wiki/love.filesystem )

EDIT:
As for how to gamify this, it would involve setting up a server, but you could let people upload their pixies and throw them into arena challenges, etc. See who wins, that sort of thing.

Another thought is to establish some in-game goals. Have this many of a given species, reach a certain aggressiveness level, etc.

EDIT 2:
Here's my pixi, P30 The Phage. It seems slightly unfair that they start each round with like 30 of them, and only 1 or 2 of all other random species. But they appeared in my first round and have absolutely conquered everything since! (I had to give the file a .txt extension so I could upload it here.)

EDIT 3:
Further testing with the Phage. I started a new game, and spawned a single Phage into it. It didn't take long for there to be over 50 of them - usually over 100 by the time they've killed off everything else. (I think I discovered a virus!) :shock:
Attachments
1-P30.txt
(8.1 KiB) Downloaded 178 times
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
ImpTea
Prole
Posts: 7
Joined: Sat Mar 06, 2021 3:37 am

Re: Pixi Dish [WIP]

Post by ImpTea »

Nice! Haha. I’m making changes all the time, don’t want to spam this thread with updates though. In the build you’re using the smaller pixies were definitely OP. After a few hours of evolving they tend to keep shrinking further and further until they’re about 1 pixel big and there’s 300+ of them lol. I’ve seen “rebalanced” in a few ways to help maintain a healthy ecosystem. Once I get this genetic shader system where I like it I’ll post the latest version.

Speaking of which, anyone got some cool shader ideas for these guys? I’ve just started learning about shaders but they are really fun to tinker with. So far the patterns I’ve got are striped, polka dot, plaid, concentric rings, sunburst, checkered, “blocky”... and I’ve got some ultra rare spawns like holographic and shiny/golden pixies. Still working out how to do some patterns like spirals, or repeating tiles like a Greek key pattern.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: Pixi Dish [WIP]

Post by Gunroar:Cannon() »

milon wrote: Tue Mar 09, 2021 7:25 pm
As for how to gamify this, it would involve setting up a server, but you could let people upload their pixies and throw them into arena challenges, etc. See who wins, that sort of thing.

Another thought is to establish some in-game goals. Have this many of a given species, reach a certain aggressiveness level, etc.
:ultrahappy: I like those ideas...
milon wrote: Tue Mar 09, 2021 7:25 pm (I think I discovered a virus!) :shock:
How?
I'm curious
:crazy: :P
Edit: Oh, The Phage is the virus *facepalm*

I can't tell when the pixis reproduce?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Pixi Dish [WIP]

Post by milon »

Gunroar:Cannon() wrote: Tue Mar 09, 2021 10:00 pm I can't tell when the pixis reproduce?
Agreed, that could be made clearer. I think when one spins like mad is when it's reproducing? But I'm not sure.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
ImpTea
Prole
Posts: 7
Joined: Sat Mar 06, 2021 3:37 am

Re: Pixi - Evolution Simulator [WIP]

Post by ImpTea »

I love some of yall's ideas about how to make it more "fun". I've definitely been toying with the idea of breeding and training pixies for combat / survival against each other. I actually wonder how feasible it is for a pixi to evolve to accomplish specific objectives, like capture the flag - I'm sure it's possible but how many generations would such an accomplishment take?

I also like the idea of giving the user goals to breed toward. The main problem here is comping up with the metric for whether or not they've accomplished the goal haha - there is no "aggressiveness" trait that can be read directly, the pixies' behavior is totally emergent from their DNA. Certain stats could be tracked I supposed (e.g., number of confirmed kills).

The "spinning like mad" is not programmed, it's just aberrant behavior due to bad genetics. It reminds me of those certain breeds of Ball Python with the mutation that makes them constantly flail/rotate their heads lol.

Anyways, here's the latest version. Major additions:
--Genetically determined shaders for pixies. Includes a few rare patterns (gold, diamond, shiny, animated).
--Balanced mechanics to give bigger pixies a fighting chance against the lil' guys.
--Reworked collision detection improving performance pretty significantly.
--Graphical effect added for when pixies reproduce. Kind of ugly but whatever.
--Added some tweening to their movement and rotation to smooth it out graphically.

Next update will be significant - I've almost completed work on a little tiny GUI library and within a week I expect to have it implemented, allowing you to change various aspects of the simulation on the fly.
Original post has been updated with the new .love but I'll attach it below as well.
Attachments
Pixi.love
(13.76 KiB) Downloaded 210 times
Last edited by ImpTea on Sat Mar 13, 2021 5:56 am, edited 1 time in total.
User avatar
togFox
Party member
Posts: 764
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Pixi - Evolution Simulator [WIP]

Post by togFox »

Will try this later and for the record, I have Single main.lua that is 3000 lines long. :)
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: Pixi - Evolution Simulator [WIP]

Post by Gunroar:Cannon() »

ImpTea wrote: Sat Mar 13, 2021 1:12 am .

Next update will be significant - I've almost completed work on a little tiny GUI library and within a week I expect to have it implemented, allowing you to change various aspects of the simulation on the fly.
Side note, while you're updating, the bar at the side doesn't fit to the screen on android. You could maybe scale it with love.graphics.getWidth/getHeight,
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 9 guests