Well yeah, the blog is like a personal diary...
I don't expect too many people to understand it.
So the server doesn't really listen to any ports yet ( it's not online yet ).
I'm going to try to explain it again in a way that doesn't look like my personal notes.
A process is a thread is a process which basically means mini-program in many of my cases, but it could actually be any size.
I start the server, it spawns a few threads... the threads that are useful are:
Beings - This maintains a list of process ids.
Logging - This handles output to the screen or whatever I want it to output to.
Heartbeat - This is the world clock basically.
Logging just waits for messages to print to the screen, it's a pretty simple process.
Beings first loads the being data from the database (sqlite)
for each being it finds in the database it spawns a separate process that maintains the being data. (stats & AI)
The Beings thread keeps track of all of these little processes so it can communicate with them via asynchronous messages.
The little being processes wait for asynchronous messages.
There are a list of known messages, when it receives a known message it does an action.
The Heartbeat thread also behaves the same way, but it has a different list of known messages, also if it does not receive a message within X miliseconds it sends out a message ({'world_tick'}) to a list of threads, one of them is the Beings thread.
When the Beings thread receives the {'world_tick'} message it passes this message to the list of stored processes.
When the individual little being threads receive the {'world_tick'} message magic happens and they go do their AI stuff.
The heartbeat thread can be paused and resumed, speed increased or decreased, this gives control over the world... which is useful for debugging.
So to summarize the server has a bunch of threads that simulate a world where "beings" do something every world_tick.
Wow... I've actually done a lot of work
There are a bunch of little things I have coded so the beings have a 'reason' to 'live'
stuff like:
Cancer/Death/Decay
- Cancer's a fun little one, it's silent until you're dead... Basically as soon as the cancer rating is more than your max hp, the being dies.
- Decay reduces hunger and fatigue, this happens every world tick. If there are no hunger or fatigue points left it takes an hp instead... yeah I know Pssh HP who needs it that's for wimps.
- Death is normal, 0 HP = Death.
Fertility/Gestation/Reproduction: Yup you can have kids, there are two birth types at the moment, which behave the same way, seed and birth. Birth has birth pains... which takes away hp, hunger, and fatigue until the child is born. seed just births the child... this is a little flawed at the moment, I'd like to make seed birth the child instantly instead of hiding the being until the gestation period is over and have it grow from seedling to plant, but that's something that can wait.
That's pretty much it for the Life cycle... there's a bunch of random stats for all of that including evolution chance and variance numbers... Explaining the Fertility cycle would take another post... there's fertility duration, fertility number, variation stats for those numbers, so it's not the same every time; blah blah blah... Birth happens.
The really interesting crap is the AI stuff... which I wont talk about in this post.
Anyway, any questions?