Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Katamori

Virtual life simulation - or whatever.

Recommended Posts

I'm a wannabe programmer who's interested in artificial life. I've already made some experiments to make something, and my final aim is to create a virtual life form that can react to the environment and things like that.

Maybe it sounds like if I'd be naive but in my opinion, if there are actors on the screen which changes their moving speed and angle constantly, then we can describe them as a very simple and useless lifeform. =)

TL;DR, I need your help. Which are the preferences that I should add my "creatures" to make them more useful and efficient?

EDIT: since a lot of valuable post has come, I changed the original title - so even if you don't want to help me, you are allowed to write something related =)

Share this post


Link to post

Question: Are you asking for programming advice? Because I'm useless there, unfortunately.

Generally speaking, I would advise you to include some randomness in its actions/decisions. It creates the illusion of the "creature" reacting to some unknown variable, and makes it seem more alive.

Share this post


Link to post

Make it voice activated and follow your habits? Like every day at this time you open these programs. make it have them ready for you?

Is this for a game or just like a desktop helper or something?

Share this post


Link to post
schwerpunk said:

Question: Are you asking for programming advice? Because I'm useless there, unfortunately.


Of course not. =) I make stuff in a game maker app. called Stencyl. It's perfect to implement most of the logic I want to put, without the formal needs of a clear programming language.

I'm learning the language C at the university but I know the basics yet only.

Share this post


Link to post
geo said:

Make it voice activated and follow your habits? Like every day at this time you open these programs. make it have them ready for you?

Is this for a game or just like a desktop helper or something?


I rather want them to act to the environment (obstacles, themselves, other creatures etc.)

It's like an experimental simulation. Of course, on the level I do at the moment, it's not more than just a game, but later I want to make something more serious. Now I'm planning the basic logics to a base of an artificial life.

Share this post


Link to post

Give it an objective. Like get from point A to B.... or kill anything within a radius of X. Or follow something. I'd say work on path finding first. Getting from point A to B. Then put an object in the way. Then determine if it can go around or over or under the object. That's a start.

If you want them to act to the environment put in variables about what they consider threats. Like do they avoid harmful gas or just run through it? Do they have self preservation where near death they'll avoid environment hazards they wouldn't while fully healthed?

When you get really complex like have an object they need to destroy... have them circle it. RTS have been doing it for decades but FPS can't seem to do it.

Share this post


Link to post

Sadly I think you lost everyone when you said Stencyl. What style would the game fit into? Top down? Side scrolling? I don't think they can do 3D, but maybe a fake 3D like Contra had.

Share this post


Link to post

What about The Game Of Life or a variant thereof?

And yeah, stay away from "game maker" tools, especially if you've just begun serious programming training: they are almost as crippling as BASIC to a novice programmer, locking you into a very limited way of thinking and preventing you from grasping essential concepts and developing required programmer skills early on.

It's much better to drudge by making simple -even trivial- programs in C, even if you will be a far cry from making a game with real graphics etc. than to get trapped into the artificially inflated sense of "proficiency" a game maker tool might give you.

Share this post


Link to post

Now I think I understand better what a life simulator is. I was imagining the Sims yet putting a FPS visual in my head :-)

Share this post


Link to post

I won't lie that I make my stuff by writing codes when it's not true. =) game maker apps are good for me to try the "logic" elements, without the formal needs, as I mentioned it before. In Stencyl, I can edit a simplier kind of codes like this:



Sadly, I'm a beginner in C, and not the graphics are my biggest problem but the fact that I don't even know, how to create an empty window with moving elements on it, or how to create random values to variables, etc. - all these things are ready in Stencyl for me.

Oh and my plans are a bit different than the Conway's Game of Life. I want to put sense to my "creatures" - on a simple way of course. =)

Share this post


Link to post

But what do you want them to do? Gather food... eat... mate... multiply?

Share this post


Link to post

I don't know yet. Maybe all of them...this is why I made this thread. "Which are the preferences that I should add my "creatures" to make them more useful and efficient?"

I think multiplying is important but the most important part of it. I'm thinking on that I shoudl create group behaviour: when one of them sees something (e.g. a tree) he triggers an event that effects the other creatures around him (e.g. help to cut the tree)

Share this post


Link to post
geo said:

But what do you want them to do? Gather food... eat... mate... multiply?

And evolve, game already exists, and it's pretty fun to mess around with.

http://www.swimbots.com/

Although said creatures only reactions to their environment is to seek out and try to find food and mates.

Share this post


Link to post

A group behavior, so its social. Then chances are they will send out drones / scouts to randomly explore, find things and then return to the others and tell them then they'll all go.

========== multiplication and evolution

Let's say you make it random every time... how much food, air and water are needed for health? Or keep it simple. How much food do they need to be healthy? When they collect 5 bits of food then they have enough to multiply. If they don't get food they slowly die. The last one doesn't die it just splits and its offspring then require the same amount of food that the previous one did.

If there is no food then it just dies or floats to where there is food. If it had to float a long time to reach the food it will grow tentacles or fins. The offspring will have them. The further it has to go for food the longer the fins.

Then there's the issue what happens if the food is hard to reach? Then it might grow arms.

Share this post


Link to post
Katamori said:

building blocks picture


Oh GAWD. Get away from that stuff as fast as you can. Once you see what the equivalent C code for that is (apart from the "switch animation" part), you'll never go back. This is simply holding you back, it's like building LEGO houses with ham fists. Using the BIG Lego Jumbo bricks.

On a side note, I've seen this "slot/wedge pieces of code together" approach before, in other "my first programming environment" suites. The complexity that you can reach before programs and projects become visually unmanageable are about 1-2 screenfuls, and the code complexity achievable is roughly equivalent to 100 or so lines of C code. Not really enough to do something as complex as what you want to do. To go beyond that, you REALLY need a "normal" programming language.

Really, get away from this stuff. It's like trying to learn from a pop-up book.

Share this post


Link to post

I agree with Maes. Its in your best interest to use something more commonly used. I think Stencyl is based in ActionScript 3 which is a terribly cumbersome language of Adobe Flash. ActionScript 2 was extremely easy to use... but eh Adobe took over and changed it.

Share this post


Link to post

I agree too. If you're going to use a game maker than at least use something with a proper scripting language. The visual clutter in that screenshot is amazing. I'm legally blind and I don't keep the fonts in my code windows that big. The strange wedge structure occupying the role of tabs and braces is just crazy.

Now of course you use a game maker for the reason that John Carmack keeps reiterating when he talks about learning game programming: new tools take too much learning and setup to get anything interesting to happen. Despite what Maes says about BASIC, at least when using it on a tiny 80s computer you could put stuff up on the screen and play with it in a matter of minutes.

It's hard to do simple game stuff in C because all those kinds of things are platform dependent and can be done in a bunch of different ways. I'm not sure what tools to recommend if you want to do stuff in C. I've only used C on Linux, and not for game-esque things.

Share this post


Link to post

Although plenty of people recommend against it... I always recommend Flash / ActionScript 2 or 3 to people. Its VERY processor intense, but Super Meatboy was made with it and various other Flash games. Angry Birds too. Otherwise Java works.

While these might not make the next Gears of War, they can make quality games.

Share this post


Link to post

You probably want to download sdl, a 2d game/sound/visual pixel stuff library. I only used it in the 'wrapper' pygame for python so far, but its for c.

Everything in the program is artificial, so for artificial life you need an artificial environment. Make it extremely simple, just something to experiment with, like a 2d array serving as a grid which is the top down world. Now you can have a list of food/trees/etc or something, each with a grid location, and creatures of different types etc or whatever.

My basic understanding is that its about :
first make some data (like each creature has an x/y/current behavior/etc. For me, this is usually big hairy multi dimension arrays because I hate OOP). If saying myArray[4][15] is a pain to remember which number stands for what you can probably do some #defines so 15 always equals "health" or some crap and you can go myArray[4]["health"] I guess (haven't really tried that much yet). Uh, maybe a hash (python dictionary) is what I mean anyway.
now loop forever until the game quits:
1)display the data on this tic (tic, tick/whatever) of time (like print stuff to the monitor)
2)probably pause for a bit so stuff doesn't happen as fast as your computer can go
4)handle events, like if you press up whatever happens (sdl deals w/ it)
4)change the data for the next tic

To make slightly intelligent stuff happen in such a simple 2d grid, you kinda need rules or something to make it more interesting, like maybe the intelligent creature can slash with a "sword" into adjacent squares, or maybe interpret it like you're skiing downward and have to dodge trees going upward or whatever.

Real life is based on replication. Once replication starts, mutations inevitably occur because replication is almost never perfect. Then the environment does its own selecting of whichever mutants happen to be most fit, which replicate their own mutants etc. See this:

Share this post


Link to post

The competing over the green cube looks like random results. ... but how do they get smarter without you programming them? Are they programmed to learn? Isn't that kind of cheating? Does that mean it makes its own code as it goes along?

So it costs energy to have kids... that's why they can't just have kids and eat them? Why wouldn't it eat the kids always no matter what? Gotta put in a genetics to protect your young.

Do these things really have little brains or is it just variables and reactions to everything around them. How exactly would changing the hue to mimic day and night instill them to stop foraging... unless it was programmed? Why not include water would it just know oh I should drink this? What if you included jello would they know its food or do they think its a wall? Do you have to give it a variable that says jello is food? How do objects kill one another when they're just squares? Do the squares measure movement and velocity vs damage and strength? I don't get the connection. How do they eat one another with no mouth? Do they acid eat things to consume them? Why not consume them while living? They didn't evolve to be red and green... they were programmed to.

I don't understand why Ply World is considered AI evolution.

Since this has been going from 1994... does that mean they have evolved into round objects and cats?

Share this post


Link to post

I'm no expert but you can probably search engine "karl sims" for more info on his experiments. Evolution is kind of a mass search algorithm; it operates on tons of individuals (dawkins says genes are the main focal point since they are the replicators, read the selfish gene; best book on evolution I've read) and can be thought of as learning in a sense. Evolution is sort of the most intelligent "thing" that exists. Its like a complete algorithmic anomaly that accidentally exploited a weird loophole in the universe allowing the effortless creation of seemingly infinitely complex things. Or something. There are ways to produce intelligent behavior without directly programming it (the universe did), such as this reinforcement learning example to make a cart intelligent enough to balance a pole:
http://www.youtube.com/watch?v=J7E6_my3CHk
(failures are punished, success is rewarded, other than that I don't remember much)

Probably on each tick of time the data just changes. But code can create other code (lisp is supposedly good at doing that and AI, but I've never used it).

I'm no expert on polyworld either, but probably a mutation could still result in a parent eating its offspring; it just wouldn't be a fit behavior due to energy costs so would die off before having many children that inherit that behavior. The brains are just bits ultimately, software, not hardware. Trying to simulate brains with neural nets. I watched the first half hour again but forget about day/night. Probably decreases how far they can "see" or something. Its just a simulation so I think what CAN evolve is programmed, like you can't just add water and expect them to do anything unless you have neurons or whatever with potential to evolve that codes to deal with it. The detailed behavior is what would evolve without needing explicit programming, like when to go toward water, how long to stay, etc. They probably kill eachother just by being removed from an array when their energy variable goes to 0 or whatever. The next tick will draw and deal with everything in that array but the dead one won't be there any more.
Real evolution took billions of years and has tons of space (the crust of the earth basically) to work with and is only limited by physics so produces much more sophisticated stuff than a simulation bound to a computer. Physics might be a "computer" too, just a much more sophisticated one. Wolfram has interesting ideas on that in the book 'a new kind of science'. His main point being that simple programs such as cellular automata are counter-intuitively capable of producing complex results such as rule 110:
http://www.foundalis.com/mat/pce/gliders.gif
therefore maybe the universe is based on a simple program, just with initial conditions so long ago that insane complexity has accumulated.

Share this post


Link to post

Maes, geo, Aliotroph?: Okay, I tell it again. I trust you because I'M just learning programming, but exactly this is the reason, why I use Stencyl. In C, I can do the simpliest thing only: loops, conditions, "printf" and "scanf", making custom functions, binary operations, and that's all about. I can't draw anything with the program to the screen (except text and numbers of course), I can't do differences between different "actors", etc.

In Stencyl, I have less functions and options to do, but at least, I can see all of them.

However, I'm thinking on that I'll work with Microsoft Visual C# 2010 because I've worked with that previously and way easier to work with than writing a whole program from a blank file in Code:Blocks or DevC++. What do you think?

gggmork: Wow, your help was very informative and useful, thank you! The videos are interesting, especially the "learning to balance" stuff.

Share this post


Link to post
Katamori said:

However, I'm thinking on that I'll work with Microsoft Visual C# 2010 because I've worked with that previously and way easier to work with than writing a whole program from a blank file in Code:Blocks or DevC++. What do you think?


That's already a bit better, as those environments usually have wizards that allow you to design windows and standard controls with ease. However, for any custom rendering, you will have to get your hands dirty, and for defining "actors" etc. you will also have to lay down your own structures/classes etc.

Geo's proposal of Actionscript is not a bad one: you get a "visual" environment for animations/sounds/images/resources (Flash), plus a C-like language that is closely integrated with the various "stage objects".

For all of its specialized nature, ACS is still TONS more flexible and closer to a "real" programming language than Stencyl. At least it will teach you something and will even allow you to reuse code written by others, something that you absolutely cannot do cleanly in Stencyl: you can only cobble together your own play-doh functions :-D

And yeah, even BASIC is much better. For all of its deficiencies, it remains a complete programming language, with enough "syntactic sugar" not to scare away beginners. Of course don't start with some 80s BASIC dialect....use some more modern variants.

A final word of advice, as a teaching assistant for the last 3 years: due to some academia fuck-ups, freshman Mech. Eng. students in my faculty are taught FORTRAN first (1st semester) AKA a hard-to-learn, irregular, and unforgiving compiled language and THEN MATLAB (2nd semester), which instead is a much more forgiving, interpreted, has "easy" plot functions etc. You'd think they'd benefit from swapping them around, right?

Not really: those that DO have the stuff to learn actual programming or at least to apply and study it (which is about 70-80% of alumni) do make it through the 2-stage course. The other 20%, just don't "get it" anyway. I've yet to see someone performing significantly better in the MATLAB part while flunking the FORTRAN one, so for me starting off with a neutered/"kid friendly" language has no didactic value whatsoever.

Share this post


Link to post

Sounds good. But I think, I should learn C instead, no matter how hard it's gonna be, because I have to learn a lot at the university (including C) so it may worth.

Anyway, I know that the developer environment is important, but I don't want to screw around with it. I want to find out the logic of the behaviour to simulate life, evolution and things like that. On the way like gggmork has explained them.

Share this post


Link to post

I'm legally blind and I don't keep the fonts in my code windows that big.


Do you run 640x480 on a 24 inch screen or is "legally blind" lingo for professional bullshitter here? I'm roughly at 20/25 visual acuity and this font size is about the smallest I could use. It's even a little uncomfortable and I would likely crank it up once for normal use. Neither of my parents, who are barely in their 60s, could use that size font at all even with correction. I used to have myopia as a child and I can remember what 20/200 visual acuity and below means, and this picture seems relatively accurate. No way anyone legally blind, defined as one tenth of normal vision after correction, could read the fonts in Katamori's screenshot, much less claim they're too big.

Save for that rant I agree with you regarding the visual clutter in there, although for me it has more to do with those enormous backgrounds containing comparatively little text.

Edit: retinas fried as in, moving black specks everywhere, stuff like that? No doubt that is extremely unconvenient. To be honest I'm still having a hard time understanding how anyone with eyesight as you have could use such small fonts, but thanks for the explanation nonetheless.

Share this post


Link to post

I wasn't kidding. 20/200 is probably as good as my best eye has ever tested (my bad eye has never even been able to see the big E). In addition to inheriting some nasty myopia, my retinas are good and fried. While glasses would make a chart like that razor sharp for me I still wouldn't be able to read it (yeah, I know that sounds like it doesn't make any sense).

Anyway, on having another look, that font isn't much larger than the one I'm using in Visual Studio right now. The spacing caused by all the clutter makes it feel bigger, though. It's also more difficult to read because the colours are sub-optimal.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×