Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Gorilla Robot
Old
jhernandez25
Junior Member
 
Status: Offline
Posts: 4
Join Date: Aug 2013
Location: Los Angeles
Unhappy Gorilla Robot - 09-04-2013, 04:29 AM

Ok just wondering if anyone might have any suggestions, am working on chapter 6 question number 16, i can make the Gorilla walk to each animal and make each animal disappear where am having a but of trouble is clicking each animal at random and after the last animal regarless of which one it is the gorilla will spin twice and look at the camera and ask where did every one go, any suggestions??????
Attached Files
File Type: a2w Gorilla.a2w (2.90 MB, 57 views)
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 09-04-2013, 06:17 PM

You have a good start here so don't give up.
The events are correct and the gorillaRobot.goToAnimal method is almost correct (In the Loop you forgot to replace the penguin with the parameter “who.”
So now the gorilla is walking toward whatever you click and when it is close enough the item disappears. This leaves a couple of questions:
1. How do you know if all the animals are gone?
1. How do you know if a particular animal is gone?
2. When does Alice check to see if the animals are all gone?
The first question is answered by writing a function, functions answer questions. The answers a function returns depends on how it is defined in the present case, we are looking for a yes or no i.e. are all the animals gone – yes or no. This runs into the subquestion How can we tell if a particular animal is gone? I am going to leave you with that question and a hint or two.
What changes when an animal is gone? And it is something YOU did in your program. So assuming you have got an answer for that part, now you need to write a Boolean function. Since it involves more than one object, I would create it under the world's functions and call it something descriptive like allGone. In the default Return statement set the value to False. Now drag an If /Else into the function. You can do your checking using nested If/Else or one If/Else and a couple of And functions (the And functions are in the world's function tab.) So it would look something like this:

allGone
If “Penguin Gone” And “Dragon Gone” And “Triceratops Gone” Then
Return True
Else
Do Nothing
Return False

So now we have an allGone function that will hopefully return True when all the animals are gone and false otherwise now we just have to use it, which gets us to question 2.
Right now you have a method called “checkIfAllAreGone” this method has (in my opinion) two problems. The first problem is that it sounds like a function that will check if all the animals are gone but it is really a method that will do a bunch of stuff whenever it is called. Whenever it is called is the other problem.
Right now your checkIfAllAreGone is being called exactly once, when the movie starts. When it runs it will carry out the two instructions in the method and exit never to perform again – unless it is called again. There are in general three ways you could cause the method to be called. For the first way ask yourself the question When do I need to check if all the animals are gone? The answer is whenever an animal has gone. So you could put the check in your “goToAnimal” method .

The other two ways both involve checking basically “all the time.” The best way to do this in an event. If you right click on the “when the wold starts” and change it to “While the world is running.” Now checkIfAllAreGone will run continously. But you only want it to run when all the animals are gone so wrap the instructions in checkIfAllAreGone with the an If/Else and the allGone function above.

That should do it.


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
thanks
Old
jhernandez25
Junior Member
 
Status: Offline
Posts: 4
Join Date: Aug 2013
Location: Los Angeles
Default thanks - 09-04-2013, 06:33 PM

Thanks once again I will try ur suggestions and hopefully I can get it to work, and thanks for being detailed :-). I probably would of taken me longer to figure it out especially since am takin the class online durin my deployment with little resources. Ill let u know how it works out form me thanks.
   
Reply With Quote
Move Random
Old
jhernandez25
Junior Member
 
Status: Offline
Posts: 4
Join Date: Aug 2013
Location: Los Angeles
Default Move Random - 09-05-2013, 10:33 PM

Wondering if someone could help when ever I add the Move random the gorilla seems to walked through the other anumals any one have an idea on how to fix this?
Attached Files
File Type: a2w Gorilla.a2w (2.92 MB, 31 views)
   
Reply With Quote
Reply

Tags
animals, disappear, gorilla


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.