This site requires JavaScript, please enable it in your browser!
Greenfoot back
nfinch1992
nfinch1992 wrote ...

2012/3/27

Can't seem to get around this.

nfinch1992 nfinch1992

2012/3/27

#
i am trying to create a scenario where red and green ants battle it out
just a pseudo code i want to attempt here

if RedAnt touches GreenAnt();
       do {
              RedAnt.eat(GreenAnt);
              new RedAnt();
else
       continue running around randomly.
       searching for ants
the other one does the same thing i'd like that the ants have a 50/50 chance of eating the other. oh since we're on it. How do i get rocks non pass through. basically i wanted to create a wall for my little ants to go around.
danpost danpost

2012/3/27

#
Since RedAnt, GreenAnt, and Rock are all sub-classes of the Actor class, you should go to the Greenfoot 'Documentation' page and select 'online' in the 'Reference' section; then check out what methods are available in the Actor class (you could check out the methods in the other classes as well). You should find methods to accomplish what you are trying to do there. BTW, if two ants both have a 50/50 chance to eat the other, then when they see each other there is a 75 percent chance that one will be eaten.
nfinch1992 nfinch1992

2012/3/27

#
thanks. i'm not quite sure what you meant by the 75 percent chance of eating eachother thing is though
danpost danpost

2012/3/27

#
If each ant has a 50 percent chance of eating another it encounters then, when two ants encounter each other Ant 1 has a 50 percent chance of eating Ant 2, AND Ant 2 has a 50 percent chance of eating Ant 1. Therefore, the possibilities end up as such: Ant 1 Ant 2 no no no yes yes no yes yes (which ever gets acted on first) The only time one does not get eaten is when both are 'no'. 3 out of the 4 possibilities has a 'yes', hence: a 75 percent chance one is eaten.
nfinch1992 nfinch1992

2012/3/28

#
i think that makes sense... i have seen this enacted in the program i made. So this does make some sense.
You need to login to post a reply.