Thrive Game Development

Development of the evolution game Thrive.
 
HomeHome  PortalPortal  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  
Welcome new and returning members!
If you're new, read around a bit before you post: the odds are we've already covered your suggestion.
If you want to join the development team, sign up and tell us why.
ADMIN is pleased to note that this marquee has finally been updated.
ADMIN reminds you that the Devblog is REQUIRED reading.
Currently: The Microbe Stage GUI is under heavy development
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Quick Links
Website
/r/thrive
GitHub
FAQs
Wiki
New Posts
Search
 
 

Display results as :
 
Rechercher Advanced Search
Statistics
We have 1675 registered users
The newest registered user is dejo123

Our users have posted a total of 30851 messages in 1411 subjects
Who is online?
In total there are 2 users online :: 0 Registered, 0 Hidden and 2 Guests

None

Most users ever online was 443 on Sun Mar 17, 2013 5:41 pm
Latest topics
» THIS FORUM IS NOW OBSOLETE
by NickTheNick Sat Sep 26, 2015 10:26 pm

» To all the people who come here looking for thrive.
by NickTheNick Sat Sep 26, 2015 10:22 pm

» Build Error Code::Blocks / CMake
by crovea Tue Jul 28, 2015 5:28 pm

» Hello! I can translate in japanese
by tjwhale Thu Jul 02, 2015 7:23 pm

» On Leave (Offline thread)
by NickTheNick Wed Jul 01, 2015 12:20 am

» Devblog #14: A Brave New Forum
by NickTheNick Mon Jun 29, 2015 4:49 am

» Application for Programmer
by crovea Fri Jun 26, 2015 11:14 am

» Re-Reapplication
by The Creator Thu Jun 25, 2015 10:57 pm

» Application (programming)
by crovea Tue Jun 23, 2015 8:00 am

» Achieving Sapience
by MitochondriaBox Sun Jun 21, 2015 7:03 pm

» Microbe Stage GDD
by tjwhale Sat Jun 20, 2015 3:44 pm

» Application for Programmer/ Theorist
by tjwhale Wed Jun 17, 2015 9:56 am

» Application for a 3D Modeler.
by Kaiju4u Wed Jun 10, 2015 11:16 am

» Translator to Serbian here
by Simeartherist Sun Jun 07, 2015 6:36 am

» Presentation
by Othithu Tue Jun 02, 2015 10:38 am

» Application of Sorts
by crovea Sun May 31, 2015 5:06 pm

» want to contribute
by Renzope Sun May 31, 2015 12:58 pm

» Music List Thread (Post New Themes Here)
by Oliveriver Thu May 28, 2015 1:06 pm

» Application: English-Spanish translator
by Renzope Tue May 26, 2015 1:53 pm

» Want to be promoter or project manager
by TheBudderBros Sun May 24, 2015 9:00 pm


Share | 
 

 Compound system

View previous topic View next topic Go down 
Go to page : 1, 2  Next
AuthorMessage
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Compound system   Thu Aug 09, 2012 12:02 pm

Further to the discussion posted by Sciocont here, I will be posting details of what we're working on here, as well as occasional prototypes.

This thread will mainly be concerned with the compound system, which is one of the most important components in building the cell and organism stages, and also the the foundations of the auto-evo system, which we'll be working on later.

I'm aiming to release something every 1-2 weeks at this stage. Most of these prototypes will be small, simple, gui's showing some part of the system working. Please DO NOT expect anything resembling a playable game for atleast the next month or two. Also, please realise that while the prototypes your seeing are fairly simple, whats going on behind the scenes is in fact very complex, the first prototype below took about 20 hours to develop over a week.

For the moment, I have a VERY simple protoype I'd like to test. Primarily, all I'd like to know is whether people are even able get it to work. What you should see, after loading, is a series of sliders representing different compounds (oxygen, water, carbon dioxide etc.), increasing or decreasing.

If you try it, can you let me know if it works, and what operating system and browser your using, thanks!

Finally, while I'd welcome feedback and discussion here, please try to keep this thread clean, if a discussion needs a seperate thread, please create one.

I'll continue this with some actual conceptual posts later this evening.
Back to top Go down
View user profile
NickTheNick
Overall Team Co-Lead


Posts : 2312
Reputation : 175
Join date : 2012-07-22
Age : 20
Location : Canada

PostSubject: Re: Compound system   Thu Aug 09, 2012 1:12 pm

It worked fine on mine. I'm using Mozilla Firefox and my OS is a Windows 7. However, as soon as I started it all the sliders start changing rapidly, my aerobic respiration plummets, then once my aerobic respiration hits zero everything else stops. I'm assuming I am not supposed to be able to tweak the sliders.

_________________
Look at how far we've come when people thought we'd get nowhere. Imagine how far we can go if we try to get somewhere.
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Thu Aug 09, 2012 1:23 pm

NickTheNick wrote:
It worked fine on mine. I'm using Mozilla Firefox and my OS is a Windows 7. However, as soon as I started it all the sliders start changing rapidly, my aerobic respiration plummets, then once my aerobic respiration hits zero everything else stops. I'm assuming I am not supposed to be able to tweak the sliders.

That's exactly what you should see. What your seeing is a cell with just a single metabolic process: aerobic respiration, which converts sugar and oxygen into carbon dioxide, water, and ATP (energy). The reaction slows down as ATP levels reach their maximum concentration, if you were to use some up in another process (as would happen in reality), respiration levels would rise and everything else would continue moving.

EDIT - oh, and I'll be posting a version which allows you some control over process rates and compound supplies later this week.
Back to top Go down
View user profile
The Uteen
Sandbox Team Lead


Posts : 1476
Reputation : 70
Join date : 2010-07-06
Age : 20
Location : England, Virgo Supercluster

PostSubject: Re: Compound system   Fri Aug 10, 2012 7:59 am

It works for me on XP in Safari on OS X Mountain Lion (King of the glacial jungle?).

You say this is going to be turned into a playable game? Will it be merged with the other prototypes, or be done from scratch?


I might as well say here that I'm impressed by the amount of development being recently done to turn concepts into logical systems, although I don't really understand the more complex civ stuff.
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Fri Aug 10, 2012 8:25 am

The Uteen wrote:
You say this is going to be turned into a playable game? Will it be merged with the other prototypes, or be done from scratch?

What I'm working on won't be merged directly with any of the other prototypes, as they were mainly written in C++, whereas this is written in C# for Unity. The reason for this is simply that developing anything in Unity is *much* faster and easier than doing so in C++. The downside is that Unity may not be powerful enough to run the complete game at a descent framerate.

As a result, the prototypes I'm writing are just that, prototypes. They're an opportunity to turn concepts into code, test them, tweak them, and optimise them, without having to worry about writing our own engine first. Some of the later, more advanced prototypes will effectively be games, and it's possible that we'll be able to create the whole cell stage this way, but I expect that at some point we will need to convert this code to c++ to create the finished game (especially the aware stage).

What this means is that we're able to develop our concepts more quickly, and get something playable more quickly, at the cost of performance and probably graphics. If and when we decide we need to switch to C++, much of the written code will need to be rewritten, but the actual methods, systems and algorithms developed will all still be valid and useful.
Back to top Go down
View user profile
ido66667
Regular


Posts : 366
Reputation : 5
Join date : 2011-05-14
Age : 102
Location : Space - Time

PostSubject: Re: Compound system   Sat Aug 11, 2012 4:42 pm

Seregon wrote:
The Uteen wrote:
You say this is going to be turned into a playable game? Will it be merged with the other prototypes, or be done from scratch?

What I'm working on won't be merged directly with any of the other prototypes, as they were mainly written in C++, whereas this is written in C# for Unity. The reason for this is simply that developing anything in Unity is *much* faster and easier than doing so in C++. The downside is that Unity may not be powerful enough to run the complete game at a descent framerate.

As a result, the prototypes I'm writing are just that, prototypes. They're an opportunity to turn concepts into code, test them, tweak them, and optimise them, without having to worry about writing our own engine first. Some of the later, more advanced prototypes will effectively be games, and it's possible that we'll be able to create the whole cell stage this way, but I expect that at some point we will need to convert this code to c++ to create the finished game (especially the aware stage).

What this means is that we're able to develop our concepts more quickly, and get something playable more quickly, at the cost of performance and probably graphics. If and when we decide we need to switch to C++, much of the written code will need to be rewritten, but the actual methods, systems and algorithms developed will all still be valid and useful.

+1

The most useless comment I have ever written?
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Sun Aug 12, 2012 2:31 pm

Ok, now for some of the theory behind the Compound System, why we need it, and how it will work.

The basic idea of the compound system is to keep track of what organisms (cells in cell stage, creatures in aware etc.) are made of. It should allow us to track what they've eaten, what they convert it into (through digestion and other processes), and what waste products they get rid of. Any compounds not in a creature (either before being eaten, or after being disposed of) are part of the environment, and available to other organisms to use.

This idea has been discussed multiple times on the forum (here, here, and here among others, though I can't seem to find the original source), I've used as much of these discussions as I can, but also made changes to help the system work in code, and allow it to fit into the biome, niche, and auto-evo systems, I'll post more on that some other time.

Components
There are four components we need to start building the compound system for the cell stage: Compounds, Organelles, Processes, and Organisms.

Compounds
Compounds represent the materials the world, and individual organisms, are made of. This includes elemental compounds (oxygen), natural resources (salt, water), organic compounds (sugar, amino acids), and organic polymers (polysaccharides, proteins, fats, DNA). Later stages will include more advanced materials as compounds (steel, plastic), as well as materials which combine many earlier compounds into a composite (muscle, bone, wood).

End products are made up of compounds, and can basically be treated as compounds themselves, these end products again differ for each stage:

Cell stage
  • Cell membranes and cell walls, which enclose and protect your cell, and must be enlarged in order for your cell to grow
  • Cilia/flagella, which allow your cell to move
  • Cytoskeleton, which allows your cell to change shape
  • Organelles, which are required to do all sorts of things, more on this below
  • Offensive/defensive structures, such as spikes if we have them


Aware stage

  • Organs
  • Horns/claws/fangs
  • Toxins


Civ stage

  • Buildings
  • Furniture
  • Weapons


Energy is an important end product in every stage, whether it be in the form of ATP in cell stage, or electricity in later civ stages.

Organelles
Organelles are the places where processes take place. Processes can't proceed unless their required organelle is present, and may be faster or slower depending on the quality of the organelle, which can potentially be upgraded, or damaged by an attack. Organelles have equivelants in later stage: organs (aware stage), factories (civ stage), cities (space stage).

Processes
Processes are the important bit. These control how compounds are converted from one to another, and what is required to do so. If an organism isn't capable of carrying out a particular process, it may not have access to that processes products, and will need to acquire them some other way (probably by eating something), or may not be able to acquire them at all (for example, eating a rhino horn doesn't allow you to grow one yourself). The processes your able to carry out, and how effectively you can do so, define your organism, your species, and your place in the food chain.

Processes can also take the form of Interactions between individuals/species, such as predation, consumption, and various types of symbioses.

Organisms
Organisms are individuals of a species, whether it be a cell, plant, or creature. Each has particular organelles/organs, is capable of particular processes, can store particular compounds, and considers others to be waste products. Each one continually carries out the processes it is capable of in order to produce the compounds it needs.

Other components
There will be many more components to making this work, but these are the most basic ones we need. A few more examples include: communities, species, biomes, niches, the environment an organism is in.

Example reactions
So, starting with the cell stage, and using 'life as we know it', we have the following system of compounds (blue, yellow and green), end-products (green), and reactions (white), which form some of the basic metabolic pathways in a cell. These reactions deal with the conversions between the three most important compound families (sugars, fats, and proteins), the production of energy (orange) via aerobic and anaerobic respiration, and photosynthesis. This diagram is already hugely simplified from reality, and missing more processes we want to include (e.g.: chemosynthesis), but it gives an idea of what it is we're trying to simulate. Note: you do not need to make sense of this diagram just yet. Click for a larger version.




With a fair bit more simplification, we can cut out a lot of the intermediate compounds above, and produce this diagram (you don't need to make sense of this one either), which shows the compounds and reactions we'll actually be using in the cell stage (again, theres a fair few missing):




Whats important is what we do next. We split this flow chart (which the computer can't make any sense of), into individual reactions/processes. Each process has inputs and outputs, which are required/produced in different ratios, proceeds at a particular base rate, and each generally requires a particular organelle or enzymatic pathway to proceed. These processes are what the computer can understand, and they're what we need to create and feed to it to get the compound system working for cell stage, more on this at the bottom of the thread. This diagram you do need to understand, but note that it doesn't include any numbers yet.



Summary
This post explains the most basic elements of the Compound System, those which are needed before we start building more complex systems (the individual stages, auto-evo etc.) on top. These elements are also what make up the deceptively simple prototype in the OP. What I've not explained in this post is how all of this is implemented, and that's what I'll be doing next.

Part of the beauty of the system is that the implementation can be completely seperated from the actual compounds, organelles and processes we choose to use. This means that we can choose to make our representation of chemistry completely accurate, ridiculously simple, somewhere in between, or make it up completely, without having to make any changes to the implementation (except that the first option would probably melt your computer). This also makes the system moddable, by allowing complete changes of the games chemistry (and in later stages, the production system) simply by changing a few data files.

This also means that, while I continue working on the implementation, others can work out the processes we want to represent, with balanced equations. If your a chemist or biochemist, please let me or Scio know so we can explain exactly whats needed.
Back to top Go down
View user profile
NickTheNick
Overall Team Co-Lead


Posts : 2312
Reputation : 175
Join date : 2012-07-22
Age : 20
Location : Canada

PostSubject: Re: Compound system   Tue Aug 14, 2012 1:35 pm

This all looks amazing, however I am no chemist or biologist to be able to constructively speculate.

I have a question regarding energy. I know that your organism will have an energy bar in-game, but how do we determine how much ATP becomes however much energy in the bar? Do we have an equation yet to determine this? This would obviously be affected by factors such as the metabolism of your organism, and it's deduction likewise affected by the energy consumption rate of your organism.

_________________
Look at how far we've come when people thought we'd get nowhere. Imagine how far we can go if we try to get somewhere.
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Tue Aug 14, 2012 1:53 pm

Thanks. Bars showing your available energy (and other compounds, if we decide the player needs to see them), will be based on the concentration of that compound within your organism, with each organism having a maximum capacity for each.

Or rather, that's the plan. It's possible that you'll spend most of your time with very low concentrations of most compounds, so we'll need to wait and see. One possibility is to use a logarithmic function (every notch on the energy bar represents a doubling of actual energy).

As for energy consumption, the hope right now is that we can find realistic rates of ATP use for each of the processes your organism undergoes.
Back to top Go down
View user profile
NickTheNick
Overall Team Co-Lead


Posts : 2312
Reputation : 175
Join date : 2012-07-22
Age : 20
Location : Canada

PostSubject: Re: Compound system   Tue Aug 14, 2012 2:24 pm

One more question, how will we manage the transition of factories being the organelles to cities, without making it seem like you are losing control of your planet?

I was thinking that players should still be able to select a city and order the construction of specific factories, but they would not have to designate where, like before, and the AI would automatically start building housing to bring in new residents to operate the new factory you just built (if it had a shortage of manpower to draw from).

_________________
Look at how far we've come when people thought we'd get nowhere. Imagine how far we can go if we try to get somewhere.
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Tue Aug 14, 2012 2:35 pm

You could allow the player to keep control of their 'capital' planet, or allow them to pick between the two systems as they wish, but I suspect the amount of micromanagement involved would become too much and most would prefer having cities be the production unit.

Also, just becuase the city is the production unit, doesn't mean there won't be individual factories, just that their effect will be combined into a single whole, hopefully that allows your second point?

Finally, to keep the discussions clean, this really belongs in this thread, which is about applying the compound system to different stages.
Back to top Go down
View user profile
NickTheNick
Overall Team Co-Lead


Posts : 2312
Reputation : 175
Join date : 2012-07-22
Age : 20
Location : Canada

PostSubject: Re: Compound system   Tue Aug 14, 2012 3:13 pm

Ahh ok, that's a good solution. I will post any other questions about implementation in that thread.

Great work!

_________________
Look at how far we've come when people thought we'd get nowhere. Imagine how far we can go if we try to get somewhere.
Back to top Go down
View user profile
Carnifex
Newcomer


Posts : 37
Reputation : 8
Join date : 2012-08-13

PostSubject: Re: Compound system   Wed Aug 15, 2012 7:58 am

Your (summarized) images of each respiration system seem to be fairly accurate. Although technically the fatty acid respiration process doesn't always result in the formation of CO2, ATP, and H2O. Fatty acids are also broken down and reused to repair/form the cell membrane (which consists of fatty acids).

Perhaps the repairing of cell membranes could be programmed into the game as well but my guess is that it would be far too deep and would only be a "cool" gimmick in the cellular stages of the game.
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Wed Aug 15, 2012 8:44 am

Actually, we do intend to include the repair, and production, of cell membranes for growing cells. The diagrams above concentrate on the core processes of the cell, not shown are end-products (which include phospholipids, cellulose, cross-membrane channels/pumps, toxins and messenger compounds).

Could you suggest some alternative forms of fatty acid respiration? I couldn't find much about it in my research, except the fatty acid -> acetyl-CoA pathway, which I then assumed would feed into the krebs cycle just as with sugar. Apart from the possibility of different electron acceptors (other than oxygen) I'm not aware of an alternative output from there?

What we really need help with is putting numbers to all these processes, so that the compounds going in and out are balanced, and especially so that we know (or atleast make an educated guess) to how much ATP is involved.

Note that we won't be simulating reactions on this level once we get past the cellular stage. I'm not yet sure how far we will simplify, but we'll probably stop tracking things like phospholipids and cross-membrane structures at that stage, as the reaction focus will shift from cells/organelles up to creatures/organs. See this thread for more details.
Back to top Go down
View user profile
Carnifex
Newcomer


Posts : 37
Reputation : 8
Join date : 2012-08-13

PostSubject: Re: Compound system   Wed Aug 15, 2012 9:14 am

That's a pretty complex biological system you're trying to simulate. I know that breaking down fatty acids into ATP produces around 32 to 38 ATP molecules, which from my recollection is around twice the amount of the glucose > ATP process.

Actually I was wrong to state that fatty acids are used to repair the cell membrane.

Instead fatty acids are used for the construction of new cells to form the lipid bilayer (membrane) of the new cell. They might actually be used for repair as well, but unfortunately I haven't been able to find much reading material about this either.

I do know the human brain (I don't know about other organisms) cannot process fatty acids as fuel, whereas the heart and skeletal muscles actually prefer to break down fatty acids as this produces far more ATP than glucose. That is what I read in my biochemistry book at least, I haven't found publicly available scientific papers on this particular subject.

*ninjaedited
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Wed Aug 15, 2012 9:41 am

Personally, I'd like to simulate this as accurately as we can, while still keeping the game playable. As I mentioned before though, the implementation is seperate from the actual system of reactions we use, so if we need to simplify, we can do so later. Also note that we won't be showing all of this to the player, a lot of the detail simply gives the auto-evo (procedural evolution) system something to work with.

To my knowledge, aerobic respiration of glucose produces 38 ATP per glucose (2 from glycolysis, the rest from the electron transfer chain), with 2-3 of those being used transporting stuff into/out of the mitochondria. Having just had a look on wikipedia (not ideal, but I don't have my biochem books to hand right now), it's suggested that each 2 carbons in the fatty acid produce 4 ATP, in addition to the 12 ATP yield from electron transport, giving you a total of 48 per 6c's, versus 36-38 per 6c's of glucose. Presumably those extra 10-12 ATPs, probably plus some extra, must be invested when the fat is first synthesised? The real payoff to fat is the energy value per gram (~9Kcal/g vs. ~4Kcal/g for glucose), rather than per carbon molecule, which may be the 2x figure you recall?

Keep in mind that all of this is comming from an ecologist, not a biochemist or molecular biologist. If you disagree with me please say so, and I'll do some more reading to check my facts.

I had heard that the brain prefers either sugar or protein, I can't think which, though sugar would make more sense. I didn't know that muscles prefered fat, I'd assumed that sugar would be quicker and easier to process, making up for the lower energy yield, but I definately do not know enough about this, so I'll go with what you said.

Actually, something else we need to know is how quickly all these reactions can take place. I suspect this will be rather difficult to find out, but I would like to be proved wrong.

EDIT: Also, a really good source I've been using is this, especially page 124 about fat and amino acid respiration. I've also realised that I've so far neglected the glycerol in triglycerides. I'm not sure how that fits in yet, so I'll have to think about it. Is fat stored in any other form (besides triglycerides and phosphlipids) within the body/cell?
Back to top Go down
View user profile
Carnifex
Newcomer


Posts : 37
Reputation : 8
Join date : 2012-08-13

PostSubject: Re: Compound system   Wed Aug 15, 2012 12:09 pm

Yeah I know most of it is all done in the background, but still these are really complex biological systems which are pretty tough to simulate accurately.
That being said, of course we can program is as accurately as we possible can so it's definitely a keeper.

You might be right about the amounts of ATP generated, I will look this up in my biochemistry book once I get back from work.
I'm not a biochemist/molecular biologist either, I have the basic knowledge and the deeper stuff I have to look up in my books as well so no worries.

I'm pretty sure your brain prefers glucose as a fuel. (source: books and www .fi.edu/learn/brain/carbs.html)
As far as I know, when the body is under large distress to the point where your body cannot supply enough oxygen for your muscles to produce energy the muscles divert to anaerobic pathways. A huge drawback from this though is that the body will deplete itself of all glucose it contains at which point you pretty much black out.

Quote from wikipedia (/wiki/Triglycerides (yes I know)):
Quote :
When the body requires fatty acids as an energy source, the hormone glucagon signals the breakdown of the triglycerides by hormone-sensitive lipase to release free fatty acids. As the brain cannot utilize fatty acids as an energy source (unless converted to a ketone), the glycerol component of triglycerides can be converted into glucose, via glycolysis by conversion into Dihydroxyacetone phosphate and then into Glyceraldehyde 3-phosphate, for brain fuel when it is broken down. Fat cells may also be broken down for that reason, if the brain's needs ever outweigh the body's.
also: /wiki/Lipid
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts : 62
Reputation : 3
Join date : 2011-12-18
Location : USA

PostSubject: Re: Compound system   Fri Aug 17, 2012 8:13 pm

hmm. The realism thing is concerning me a bit. The effects of some of these processes will not be present to the player unless it involves ATP(energy) and probably protein(health? Organelles? Editor?) Yes, in real-life you don't get these things out of nowhere, but in gaming, anything is possible and the coding doesn't have to be done for allot of these background processes. I know it's possible, and not even very difficult to program these different processes realistically, but is it worth the memory? Are the results worth the processing? Who will notice these results? There's a bit to consider when dealing with these things. We don't want to make useless objects and classes, the results must justify the means. However, besides that I like the direction we're going in with compounds and things. This is my favorite thing about this post:
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Fri Aug 17, 2012 8:26 pm

I realise the realism I'm aiming for might not be possible, but I think if we can pull it off, it'll be worth it. Also, as I said before, the implentation is completely seperate from the actual level of detail we use for the compounds. We create the classes to support the system (I've done an early version of this already), and the objects are created dynamically from xml data files. If we find out that the level of realism we wanted isn't computationally possible (or necessary for gameplay), we change the data files, not the code (which I realise isn't trivial either, but it's easier than rebuilding the engine).

I keep saying I'll post some implementation details soon, and things keep comming up. I'll try to finish it over the weekend, and will post it either Sunday or Monday. Until then, sorry for not making it entirely clear how I intended to make this possible.
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts : 62
Reputation : 3
Join date : 2011-12-18
Location : USA

PostSubject: Re: Compound system   Fri Aug 17, 2012 8:57 pm

Seregon wrote:
I realise the realism I'm aiming for might not be possible, but I think if we can pull it off, it'll be worth it. Also, as I said before, the implentation is completely seperate from the actual level of detail we use for the compounds. We create the classes to support the system (I've done an early version of this already), and the objects are created dynamically from xml data files. If we find out that the level of realism we wanted isn't computationally possible (or necessary for gameplay), we change the data files, not the code (which I realise isn't trivial either, but it's easier than rebuilding the engine).

I keep saying I'll post some implementation details soon, and things keep comming up. I'll try to finish it over the weekend, and will post it either Sunday or Monday. Until then, sorry for not making it entirely clear how I intended to make this possible.

I'm all for working with those process charts you provided. The player has several ways to gain ATP and protein. Each process will give different results but, have different requirements if you want those results. This will force the player to explore the in game microbial world for various required substances or cells with the DNA for special organelles the player needs/wants which they acquire by say, assimilating with that cell? Or I suppose we could have a game mechanic where after constantly collecting certain required substances, an organelle is evolved to generate this required substance for the cell so less energy is wasted wandering(imagine how rewarding that might feel to unlock after all your searching and gathering).
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Mon Aug 20, 2012 2:09 pm

Sorry again for the delay in posting this, hopefully this makes it clear exactly how I propose the compound system is implemented, and what this means we need to do from here. I had intended to post some code and actual implementation specifics, but that will wait until we've decided on some coding standards later this evening. Instead, i'll concentrate on the actual algorithm, what it requires, and any code specifics I'm more confident on.

So we know the basic components needed for the Cell stage Compound System (compounds, organelles, processes, and organisms), now lets see how each one works, how they fit together, and how all of this is implemented in code. There are two reasons for posting this, firstly to explain whats going on for those of you who are interested, and secondly to show just how much difference there is between a concept and an implementation, and just how much detail is needed for the latter.

Definitions
First of all a few definitions. For the purpose of this post only, component types are the different types elements which go to make the complete game system (e.g.: compound, organelle, organism, biome, niche), whereas components are examples of each of these types (e.g.: oxygen, water, chloroplast, creature a/b/c, tropical rainforest).

Most of the numbers I use below are examples, the actual values will either need to be researched, or decided on, at some later point. These values will need balancing, to make the game playable, and fun (i.e.: not to difficult, not to easy). The exceptions to this are the molecular weights listed for compounds, these are scientific fact (unless I've made a mistake somewhere!).

Any number followed by an 'x' indicates that that particular compound is divided into units. For example, polysaccharides (e.g.: starch, cellulose) are made up of many sugar units in a chain, that number could be anything from 2 to 50 or more. Each individual sugar is a unit, so that where it says that the molecular weight of a polysaccharide is 180x, that means the actual weight is 180 times the number of units. Similairly, if an organism has a storage capacity of 500x for starch, it means it can store a total of 500 starch units, regardless of how many individual molecules that starch is divided into (in fact, we don't bother keeping track of individual molecules at all, this total is all we need to know).

Elements in the diagrams I give below are color coded along to the following key. Apologies to anyone whos colorblind, but the software I'm using to make these doesn't give me many alternatives for highlighting nodes, if this is a real problem, please let me know and I'll try to work on an alternative.



The properties I've used for each component are simply examples, I don't yet know whether these are all the properties we'll want to use, or if we'll want to use all the properties I've listed, they're simply what I've started off with.

Classes
Each component type is defined in code as a class (that is, a collection of properties and functions which act on those properties). You can use a class definition to create objects, which have the structure of that class, but their own data, which may or may not be unique to that obect (see a programming tutorial for more details). So, for example, we have the classes: Compound, Organelle, Process, and Organism. Example objects are Oxygen, Water, Glucose (Compounds), Mitochondrion, Chloroplast (Organelles), Aerobic respiration, Photosynthesis (Process).

In this implementation, each object contains the constant data about a particular component, that is, the data which is the same for all examples of that component, in programming terms this data is 'static'. So, for compounds, their molecular weight will always be the same, as will their name and icon, other possibilities would be melting/boiling temperatures:



What this definition doesn't include is information like how much of the compound a cell can store, as this is particular to the cell storing the compound, not the compound itself.

Status classes
In addition to storing a reference to the static data about any component it uses, most components will also store some additional data about the used component alongside it. To clarify, here's an example.

The process shown below has various properties. Alongside a name, it has a basic reaction rate, at which it is carried out. It then contains three lists of components: input compounds, output compounds, and organelles. For each compound it also lists the number of that compound which is either needed or produced by the reaction, this is the status of that compound for this particular process.



In a more slightly complicated example, consider the compounds stored by a particular organism. For each compound, the organism has a particular capacity, and also a currently stored quantity of that resource, these values and others would be combined into a 'Compound Status' object for that organism.



Process evaluation
So now we know how we're storing all this information, and how to access it, what do we do with it?

At set time intervals, the entire game is updated, though different aspects of the game are updated at different rates. The fastest is the graphics you see, which are updated every frame, roughly (hopefully) 30-60 times per second (fps). Roughly twice a second we'll update the levels of each compound within the system (i.e.: the number of units we have of each), fast enough to appear smooth to the player, and slow enough to stop your computer melting. Somewhat less often (every 2-5 seconds) we'll update the rate at which these compound levels are changing (i.e.: the change in units per second), according to the processes being carried out in each organism. These updates are desynchronised, so that each frame only a small subset of all the updates is carried out, which helps to smooth the framerate.

The only 'moving part' in the compound system as it is right now is the processes, which convert input compounds into output compounds, changing the quantities of each in whatever location that process is being carried out, which could be an organism, or the environment. For now then, process evaluation is the only thing we need to worry about in terms of actually doing anything. Here then, is the current algorithm for process evaluation:

For each organism (o), for each process (p) that organism can perform:

  1. Fetch the basic rate (R_b,p) at which that process can be performed (static process object)
  2. Multiply that rate by the concentration (C_c) (current store / maximum capacity) of each input (P_ic,p) compound within that organism
  3. Multiply that rate by the inverse concentration (1-C_c) of each output compound (P_oc,p) within that organism
  4. Multiply that rate by the available space within the organelles (G_g) available in the organism, which are required by the process (P_g,p)
  5. We now have the total rate (R_p) at which the process is proceeding.
  6. Now, for each input compound used by the process, change the rate of change of that compound (R_c) by -1 x R x Pin_p,c (the quantity of that compound used by the process)
  7. For each output compound used, change the rate of change (R_c) by 1 x R x Pout_p,c


Now, at each compound update step, we use this rate of change (R_c), to modify the level of each compound within an organism. Excuse the variable naming, the level of nesting makes this rather awkward. Anyway, here are some formatted equations for the above:


The reaction rate of each process within an organism:

The resulting rate of change for each compound within an organism:


Now, at each compound update step, we simply add R_c to the quantity of compound c stored in the organism... simple, really.

Now, to anyone who thinks this is hugely complicated, your probably right, but as far as the computer is concerned this is really basic number crunching, and computers are *good* at number crunching. The result then, is that while this process is rather difficult to understand, it's fairly simple to code, and not excessively expensive to compute.

Summary
Thats pretty much it for now, theres a lot more details to work out, both on the concept and the implementation, but this roughly covers whats going on in the prototype posted in the OP. What I'd like to know from you (apart from any general comments or suggested changes), is whether you actually want posts like this in future, with actual implementation details. I'll continue posting maths along with concepts as and when I can, but I'm not sure whether it's worth explaining the program structure (everything before the 'Process evaluation' section) as I go along? Let me know what you think, and whether you'd like more. Also, if your having difficulty understanding any of this, let me know and I'll try and make my explanation clearer.

The compound icons I used are borrowed from turbosquid, perhaps someone more artistically talented would like to have a go at comming up with some chemical icons, similair to these but using the thrive shard theme? (for an added challenge, keep them recognisable at 64x64 or 32x32 pixels). Here are few more to get you started, note that the angles between atoms in the icon doesnt really matter, so long as the order is kept the same:



The same goes for the mitochondrion icon, which came from here.

tl;dr; - understandable really, but now you know why it took over a week to write a simple prototype.
Back to top Go down
View user profile
Seregon
Regular


Posts : 263
Reputation : 37
Join date : 2011-08-10
Location : UK

PostSubject: Re: Compound system   Tue Aug 21, 2012 12:29 pm

I missed a fairly important point in the post above. As I've said before, the actual compounds, organelles, and processes using the game are dynamically created from datafiles. These files are (currently) provided in XML fomat. If we (or future modders) ever decide to change the game chemistry (e.g.: to simplify it), all that needs to be done is to change these datafiles, not the game code. Similairly, this same system could be used to add products, resources, and production paths to later stages.

Example xml files are below, not that the properties included here are only what I've worked with so far, we'll likely add many more (for example those included in the images in the previous post). The actual xml structure used could probably be improved too, so if you know more about that than I do, please do offer any suggestions or comments.

Compounds.xml

Organelles.xml

Processes.xml
Back to top Go down
View user profile
NickTheNick
Overall Team Co-Lead


Posts : 2312
Reputation : 175
Join date : 2012-07-22
Age : 20
Location : Canada

PostSubject: Re: Compound system   Tue Aug 21, 2012 2:35 pm

This all looks wonderful!

One question, however. Do the other programmers have other sources of accessing your compound system? If this is the only place where they can see the model then I think it is important to keep the implementation details as it would greatly help them become as adept with the whole model as you are. Otherwise, if they have alternative sources of accessing the details of the implementation of the compound system, I would refrain from posting the same details here unless someone requests it. I just think it is more important for you guys to do the coding than to take time/effort away from that to tell us how you are coding.

_________________
Look at how far we've come when people thought we'd get nowhere. Imagine how far we can go if we try to get somewhere.
Back to top Go down
View user profile
ido66667
Regular


Posts : 366
Reputation : 5
Join date : 2011-05-14
Age : 102
Location : Space - Time

PostSubject: Re: Compound system   Tue Aug 21, 2012 11:12 pm

Seregon wrote:


The reaction rate of each process within an organism:

The resulting rate of change for each compound within an organism:



tl;dr; - understandable really, but now you know why it took over a week to write a simple prototype.

Soooo....
The rate of change = The sum of the rate and Quantity of output - the sum of the rate and the Quantity of Input.
Back to top Go down
View user profile
~sciocont
Overall Team Lead


Posts : 3406
Reputation : 138
Join date : 2010-07-06

PostSubject: Re: Compound system   Thu Aug 23, 2012 5:58 pm

I can take a crack at icons. You're doing great work, seregon.

_________________
Remember our goals: simplicity, science, and playability. Keep them in mind always.
[OE]|[FAQ]|[Wiki]|[My Blog]
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Compound system   Today at 4:37 pm

Back to top Go down
 
Compound system
View previous topic View next topic Back to top 
Page 1 of 2Go to page : 1, 2  Next

Permissions in this forum:You cannot reply to topics in this forum
Thrive Game Development :: Development :: Programming :: Technical Discussion-
Jump to: