This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-11-04 22:30:31

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Genetics

Would it be possible to make a game where you click a sire and a dam and then "mate" them? Then when you mate them, you get to see what the offspring look like? I would like to make it so you have to breed for a particular trait, then when you achieve that trait, you proceed onto the next level.

Something kind of like this game:
http://pbskids.org/dragonflytv/games/game_dogbreeding.html

I am making it for a school project. It would be great if I could download this game, add it onto a CD or something, then take it and put it on a laptop at the school Science Expo, so I was also wondering if there would be a way to do that as well?

Thanks!
Emily

Offline

 

#2 2012-11-05 10:46:08

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Genetics

Really it depends how complex you want it. If you just want it to pick a random colour our of the two that mate, that's easy, if you want it to have a chance of a small variation, still easy. If you want things like recessive and dominant genes, that's a bit harder. Do you just want them to change appearance or have them be able to do things?


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-11-05 12:12:39

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Re: Genetics

I would like them to take from a predetermined Sire (Aa) and a predetermined Dam (Aa) and breed them to make offspring. Then you get a predetermined outcome, but it randomly chooses one of the outcomes to show (AA, Aa, Aa, aa), and you need the recessive one (aa) to proceed onto the next level. It would be neat if it "saved" the animals you've bred for that round, so you can breed them as well.

Offline

 

#4 2012-11-06 01:13:33

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Re: Genetics

What I was thinking was when you clicked the sire or the dam, it would change their genetic codes into the next genetic code. Then you clicked a button and it would produce a random number of babies (1-5) with different genetic codes, but have them based on the parent's codes (IE: you will not get an "aa" offspring from an "AA" parent).

So far, I have three genes I would like to use. A, B, and D.

Would there be a way to make it so that there is an objective to the game as well? Like, you must breed a certain genetic code to move onto the next level. Making it somewhat like a puzzle.

Thank-you so much for taking your time to reply to my message!
Emily

Offline

 

#5 2012-11-06 12:02:00

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Genetics

I'm writing the code now, I assume you have a working knowledge of scratch, should I do it here or in a project?
EDIT:done it here

when gf clicked//this can go in any sprite, or the stage
delete [all v] of [genes v]
add (parent's genes) to [genes v]//do this for all parents
add (other parent's genes) to [genes v]//or use a variable to make random ones
set [gene setter v] to (1)
set [genes chosen v] to (0)
broadcast [begin v]

when I receive [begin v]//this needs to be in all parents
set [gene# v] to (gene setter)//gene setter needs to be a global, gene# needs to be local
change [gene setter v] by (1)
forever
if <<touching [mouse pointer v]?> and <mouse down?>>
if <(genes chosen) = (0)>
set [gene1 v] to (item (gene#) of [genes v])
else
set [gene2 v] to (item (gene#) of [genes v])
end
change [genes chosen v] by (1)
wait until <not<mouse down?>>
if <(genes chosen) = (2)>
repeat (# of children)
add (join (letter(pick random (1) to (2)) of (gene1)))(letter(pick random (1) to (2)) of (gene2)) to [children v]
This fills the list called children with codes made up of random selections from the two parents. You could then clear the parents list if you wanted and add the children to it. If you need more help with the conditionals (winning from certain codes etc) just say

Last edited by zammer990 (2012-11-06 12:10:59)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#6 2012-11-06 14:18:19

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Re: Genetics

This may be really weird to say, but I have everything but the
[scratchblock]
add (join (letter(pick random (1) to (2)) of (gene1)))(letter(pick random (1) to (2)) of (gene2)) to [children v]
[/scratchblock]

Apparently, mine does not have this feature? Or maybe I'm not looking in the right area?

Thank-you again for all of your help.

Offline

 

#7 2012-11-06 15:23:04

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Genetics

MissEmily wrote:

This may be really weird to say, but I have everything but the

add (join (letter(pick random (1) to (2)) of (gene1)))(letter(pick random (1) to (2)) of (gene2)) to [children v]
Apparently, mine does not have this feature? Or maybe I'm not looking in the right area?

Thank-you again for all of your help.

The problem was that you forgot to put an "s" after scratchblock. Anyway, fixed.

Last edited by ErnieParke (2012-11-06 20:13:06)


http://i46.tinypic.com/35ismmc.png

Offline

 

#8 2012-11-06 20:08:12

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Re: Genetics

I'm sorry for the confusion. I meant that I do not have the red-orange scratchblock that says "Add {VARIABLE} to [VARIABLE]"I have everything but that block. I've looked through all of my blocks, even the other colors, and I do not have that block. Maybe I have an earlier version or something? I'm not sure. I just can't find this scratchblock.

Offline

 

#9 2012-11-06 20:15:29

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Genetics

MissEmily wrote:

I'm sorry for the confusion. I meant that I do not have the red-orange scratchblock that says "Add {VARIABLE} to [VARIABLE]"I have everything but that block. I've looked through all of my blocks, even the other colors, and I do not have that block. Maybe I have an earlier version or something? I'm not sure. I just can't find this scratchblock.

That script is adding a variable to a list, not a variable to a variable. You'll find lists and their blocks under "variables"  wink


http://i46.tinypic.com/35ismmc.png

Offline

 

#10 2012-11-06 21:53:19

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Re: Genetics

OK! I found it! It was in the "Make a List" part. That was why I could not find that block. Thank-you so much for the help!

Offline

 

#11 2012-11-07 02:45:23

MissEmily
New Scratcher
Registered: 2012-11-04
Posts: 7

Re: Genetics

OK, I am proud to say, that I have everything entered in! I feel so very happy now!

OK, this is where I am at now:
I have the top code entered, and I have it figured that it is what simulates the parents passing on the genes to the children.
I have the parent sprites created, with the different phenotypes as costumes (there is 8 phenotypes) and two offspring (a male and a female) with the phenotypes as their costumes as well.

Now, I think I have to make it so it associates costumes with genes. Like, associates "AaBBdd" with the "Blue Agouti" costume. And make it so that, when I click it, it switches both costumes and genetic coding. Then, also make a way that you click something to trigger the parents to pass on their codes and make 1-5 offspring.

I know how to make it switch costumes, but puzzled at making it switch genetic coding as well.

I've decided that it is probably unreasonable right now to make it into a game, when I do not have that much experience with Scratch. It would be much more of a burden to try and get people to help me all the time with it (more than I am now). I've been watching tutorials on YouTube lately and playing around with adding things together and trying to see what each does.

And, again, thank-you so much with helping again! I am so very excited to kind of get to see my little project (which is looking like a very large project now, LOL!) start to kind of take form! I've already started to have ideas like how to display my game ideas on my science board for the Expo and really make everything look amazing! I am so very excited about all of this!

Offline

 

Board footer