So I need to learn c++ for a job interview (which I imagine you guys will not want me to get as it’ll be stressful and take up all my time, lol).
Anyway I thought what better way to practice than write a program I’ve been meaning to write for a while. So basically what this does is it takes a string of letters and turns it into a body plan for a microbe. This means you can start the game in a procedurally generated patch with random microbes all around you (if we want to go that way).
It took a while to figure it out and it’s very inefficient (checking the same spaces 20 times) however what it can do is place any rectangular organelles (they have to be rectangular) on the hex grid such that they don’t overlap and such that all the exterior organelles (flagella, toxin, agents, pilus etc) are around the edge and the interior organelles are in the center. Moreover the microbes should come out circular as I used the distances on the hex grid to try and get each new organelle added as close to the center as possible.
Also it makes these cool ascii art microbe plans. Here are some examples. (n = nucleus, c = cytoplasm, h = chloroplast, m = mitochondria, v = vacuole, f = flagella, t = toxin which I think is all the organelles we have right now). Can you work out which shapes I have arbitrarily chosen for each organelle (these should be changed to the real values)?
List of Organelles to make : ncchcmccvmffftf
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . f . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . t . m m f . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . c c h h . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . c n n v v . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . c c n n v v . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . f . m m . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . f . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List of Organelles to make : nchmcchhmvtttft
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . h h . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . t m m h h . t . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . c n n h h . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . t . c c n n f . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . m m . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . t . v v . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . v v . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List of Organelles to make : ncmmvmvvhmttfft
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . f . . . t . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . m m . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . t v v m m h h . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . v v n n v v . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . t v v c n n v v . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . v v m m . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . f . m m . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
So yeah if we add the ability to read these codes from a file it’ll be really easy to share setups (like if you find a cool microbe you just need to find out it’s code and you can share it on the forums and people can load it into their games really easily).
It also opens the door to a super basic auto evo because each time the player goes to the editor the code of one ai species could be altered (add an organelle up to 20 max or take one away down to only nucleus and 1 cytoplasm remaining) and so the patch would change over time as you play. Of course this will be a random change and so it won’t make much sense however it will be at least a step in the right direction (it’s gonna take like 1000 lines of code to figure out which letter is the best to change, lol).
As far as AI goes maybe the best solution is to say “if you have no flagella do nothing, if you have flagella and no toxin then run from the player, if you have flagella and toxin try to go towards the player firing toxin, if you have only toxin then fire when the player is near”. So at least the ai will update a little bit when the microbes are changed (though if this is a lot of hassle then maybe it’s better to wait until we can write proper ai.)
Anyway yeah all feedback welcome, code is here. It’s horrible but it’s the first c++ program I’ve written.