Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Evolution type thing
#1
I was this post and thought it would be kool to give it a try. Trouble is, as soon as I start coding it I get the basic layout for it set out and then as soon as I get thinking about the more complicated parts of the project my mind just gets overloaded with information. I was wondering if there was anyone who would like to work on it with me? Anyway, just to show you the kind of style I was thinking of here's what I got so far, but two things; first of all, I realise that what I have so far is a bit pants; secondly, I realise now that germs just divide themselves in two but this is a project that's been popping in and out of my head for aaaaaggges so I decided it would be kool to use the fibonacci pattern for it.

Code:
SCREEN 19
randomize timer
oldnum% = 1
bacteria% = 1

TYPE cells
   posx AS INTEGER
   posy AS INTEGER
END TYPE

DO
   LOCATE 1, 1
   PRINT "Germs: " + STR$(bacteria%)
   temp% = bacteria%
   bacteria% = bacteria% + oldnum%
   oldnum% = temp%
   DIM germs(1 TO bacteria%) AS cells
   FOR X% = 1 TO bacteria%
      germs(X%).posx = INT(RND * 800) + 1
      germs(X%).posy = INT(RND * 600) + 1
      PSET (germs(X%).posx, germs(X%).posy), 2
   NEXT X%
   LOCATE 1, 1
   PRINT "Germs: " + STR$(bacteria%)
   press$ = INKEY$
   IF press$ = "q" THEN
      EXIT DO
   END IF
   SLEEP 1000
   CLS
LOOP

Post your ideas or comments on how to do stuff. I've only just started work on this again so I may be updating this with extreme
regularity so keep your eyes peeled for new functions etc.

Jack :-)
Reply
#2
Intresting... tho, you should change the Press$ IF for the "ESC" key, it makes your demos more user friendly, and do it in the FOR..NEXT loop sence thats the one looping the most... so it check for key presses every loop...

Here,.. like this:

Code:
SCREEN 19
randomize timer
oldnum% = 1
bacteria% = 1

TYPE cells
posx AS INTEGER
posy AS INTEGER
END TYPE

DO
LOCATE 1, 1
PRINT "Germs: " + STR$(bacteria%)
temp% = bacteria%
bacteria% = bacteria% + oldnum%
oldnum% = temp%
DIM germs(1 TO bacteria%) AS cells
FOR X% = 1 TO bacteria%
germs(X%).posx = INT(RND * 800) + 1
germs(X%).posy = INT(RND * 600) + 1
PSET (germs(X%).posx, germs(X%).posy), 2

press$ = INKEY$' Changed, placed in FOR..NEXT
IF press$ = CHR$(27) THEN END' Changed, Uses ESC key..

NEXT X%
LOCATE 1, 1
PRINT "Germs: " + STR$(bacteria%)
SLEEP 1000
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#3
whoa, that is some prettty funky coloring/formatting O.o

edit: i just realized its cuz the command names are BLACK, the same color as the code box in smart dark, erm...
Reply
#4
Yeah, that's odd. It's hard to see the keywords.
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Reply
#5
*Switches to smartdark*

:o Oh crap!!!!! I forgot about that.... doesn't help, FB Ide automaticaly does black.... hang on a sec...

Edit... There.... Tongue
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#6
So, ummm. Any ideas? Anyone?
Reply
#7
I get the whole random germ idea... where do you want it to go in the big picture?

Me, on the current demo.. I'd make it so the first germ would slit, and another germ come off of it, then those splite and so on... taking the random scattering effect away... making it more realistic... :wink: But as for germs, is that all,. or do you plan to increase apon it?
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#8
I kind of plan to increase on it.

Now, before I continue I'd like to say this; what I'm about to write is probably going to be an un-censored flow of ideas coming out of my brain, so if I repeat myself or anything else stupid, please forgive me.

First of all, I started out hoping to make it how you said, only that meant introducing stuff like generations and parenthood (or at least that's how I originally planned it). Also, I was flicking through this book I have on AI and reading the article about the game 'spore' and I was hoping to have a strange mixture of Genetic Thingies (can't remember the full name off the top of my head) and different germs preying on each other creating a need for evolution so I was thinking of including random mutations through every new germ born and germs having a greater and greater probability of dying for every 'year' (new set of births) after a certain amount, I sort of got it working once and found it worked best if they started getting into 'old age' after three 'years'. I was thinking of introducing 'plant germs' and 'herbivore germs' and trying to seriously figure out how to get the whole evolution thing working so that eventually different interactions would take place, i.e. 'carnivore germs' and 'parasite germs' and I was thinking of making it so that where there were more 'dead germs' the ground would be more 'fertile' and therefore 'plant germs' which would attract more 'herbivore germs' etc leading to more 'mating' (another concept I want to introduce) which would lead to more random mutations. On that note I was thinking of introducing the idea of selective breeding as well. I know there's more up there in that brain of mine but right now I haven't thought this through well enough. I know that this all sounds like a lot based on what I've shown you, but unless one/some of you guys lend me a rather big hand I'm figuring that this will be an extremely long term project, but that's okay with me, I like taking on projects that are out of my reach.

Jack
Reply
#9
Somebody had this idea once. And actually I've continually wanted to do this over and over again. It's a neat idea. Look at this thread:
http://forum.qbasicnews.com/viewtopic.php?t=7055
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#10
Okay, I haven't started coding all of the functions like getting food and reproducing but I've designed a basic frame for those to be written onto. Here it is...

Code:
'(C) copyright Jack Davies 2005
'Okay, that was unnessercery but it felt good.
'This is supposed to simulate evolution but will be a long project.
'I've never really commented code too extensively before but I've decided that
' it's time for a change so I'm going to over-comment.


'800x600 pixels
SCREEN 19

'for making random stuff, urm... random
RANDOMIZE TIMER

' This variable is used for REDIMing the cells array to the correct number of germs.
germs% = 1
' This is used every time a new germ is born to keep track of what generation it is from.
' See notes in the main loop.
generation% = 1

' Creates the 'germ' type.
TYPE germ
   ' "X" position on the screen (1 TO 800)
   locx AS INTEGER
   ' "Y" position on the screen (1 TO 600)
   locy AS INTEGER
   ' The maximum distance (in pixels) that the germ can travel per 'turn' for
   ' lack of a better word
   speed AS INTEGER
   ' 1 OR 2 (consider parralell to male OR female)
   gender AS INTEGER
   ' 1 TO 16 (number of possible colors) However this does not mean that this
   ' is the maximum number of combinations for germs as this combines with generation
   ' which will (usually) be stronger, faster and generally better than the last.
   breed AS INTEGER
   ' How much strength the germ has to kill other stuff so that he can eat it.
   strength AS INTEGER
   ' How old it is.
   age AS INTEGER
   ' How many parents it had. Important for deciding the method of reproduction.
   number_of_parents AS INTEGER
   ' What generation of its breed the germ belongs to.
   generation AS INTEGER
   ' How much food can be taken from that germ at that exact time.
   food_content AS INTEGER
   ' How much energy a germ has affects how much of its speed and strength it
   ' can use. The maximum is 100 for energy.
   energy AS INTEGER
   ' What its maximum food intake is. When energy is at 100 and the germ still
   ' eats then its fat goes up.
   max_food_intake AS INTEGER
   ' Whether or not the germ can move. If, for example, the germ is a 'plant germ'
   ' then it would not be able to move. Also, it may be extremely unlucky in its
   ' evolutionary mutations.
   capable_of_movement AS INTEGER
   ' Whether or not it's alive. Used mainly for the person writing the code to tell
   ' the program which germs to keep active, ie, which germs can eat, reproduce, be
   ' eaten, and most of the time, move.
   alive AS INTEGER
   ' The fat variable has the opposite effect of the energy variable meaning that
   ' the less fat there is, the better for the germ, ie, the germ would not move
   ' as quickly if it had lots of fat. However, while a germ contains fat it will
   ' not lose energy but when the germ was going to lose energy it would lose fat.
   fat AS INTEGER
   ' Useful for stuff like parentage.
   id AS INTEGER
END TYPE

' Creates the 'earth' type, there is one of these per pixel.
TYPE earth
   ' "X" position on the screen (1 TO 800)
   locx AS INTEGER
   ' "Y" position on the screen (1 TO 600)
   locy AS INTEGER
   ' How much food that pixel stores, starts off as a random variable and then
   ' is affected as time goes by depending on how much it is fed from and how
   ' many plant germs are there.
   food AS INTEGER
   ' How many nutrients that pixel contains, affected by how many germs die within
   ' a three pixel radius of that pixel.
   nutrients AS INTEGER
END TYPE

' DIM's the cells array, the cells array stores every single germ ever spawned,
' dead or alive.
DIM cells(1 TO germs%) AS germ

' Create the first germ.

' Sets the 'locx' variable of the first germ as a random number between 1 and 800
cells(1).locx = INT(RND * 800) + 1
' Sets the 'locy' variable of the first germ as a random number between 1 and 600
cells(1).locy = INT(RND * 600) + 1
' The first germ is a static, useless germ with only one perpose, to split and
' generate mutations every time it splits.
cells(1).speed = 0
' Set's the gender of the first germ.
cells(1).gender = INT(RND * 2) + 1
' Sets the breed of the first germ.
cells(1).breed = INT(RND * 16) + 1
' Sets the strength of the first germ.
cells(1).strength = 1
' The first instruction in the main loop is to up every living germs age by one,
' so, if I gave it an age of 1 to start with he'd be 2 years old the first time through.
cells(1).age = 0
' This has to equal one or more because otherwise he would not split in 2 and
' create little baby germs.
cells(1).number_of_parents = 1
' He's the first generation.
cells(1).generation = 1
' Why not? Threes a good number
cells(1).food_content = 3
' He's done nothing, so his energy is full.
cells(1).energy = 100
' He's the first generation, let's let him evolve to get better.
cells(1).max_food_intake = 1
' He can't move
cells(1).capable_of_movement = 0
' He's alive.
cells(1).alive = 1
' He's eaten nothing so why should he have any fat?
cells(1).fat = 0
' He's the first so his ID is 1. the seconds will be 2 etc, etc...
cells(1).id = 1

' Generate the world.
DIM world(1 TO 480000) AS earth

' These are the locx and locy things. See further on to get what I mean.
X% = 1
Y% = 1

' Z% is every pixel.
FOR Z% = 1 TO 480000
   ' The 'X' position of every single one.
   world(Z%).locx = X%
   ' The 'Y' position.
   world(Z%).locy = Y%
   ' How much food it contains.
   world(Z%).food = INT(RND * 10) + 1
   ' Starts with zero and goes up for every germ that dies on that pixel.
   world(Z%).nutrients = 0
   ' Increase the Y position by one every time.
   Y% = Y% + 1
   ' Moves along to the next column every time the previous one is filled.
   IF Y% = 600 THEN
      X% = X% + 1
      Y% = 1
   END IF
NEXT Z%


'main loop
DO
   ' Moves the generation up every time. This works as there are always germs that
   ' divide in two to reproduce, :. a new generation is brought around every loop.
   ' By the time that all the asexual germs have been killed off there will
   ' have had to be enough sex-having germs to have killed them off who will be
   ' producing at least one kid per loop. I know that isn't a very programmery,
   ' think of every possibility, way to look at it but heck, it's the way I'm gonna
   ' do it. For now.
   generation% = generation% + 1
   FOR z% = 1 TO germs%
      ' Make sure that the germ you're dealing with is alive so you don't get
      ' "Primordial Soup Of The Living Dead".
      IF cells(Z%).alive = 1 THEN
         ' Up every living germs age by one.
         cells(Z%).age = cells(Z%).age + 1
         ' Show the germ on the screen
         PSET(cells(Z%).locx, cells(Z%).locy), cells(Z%).breed
      END IF
   NEXT Z%
   ' Wait one second.
   SLEEP 1000
   ' Clear the screen so that the germs can move next time round.
   CLS
LOOP

So there it is. Post any ideas you have, play around with it and tell me what you think. I'll keep you posted.

Jack
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)