Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
LadyBug's Suppertime!
Old
hieu89
Guest
 
Status:
Posts: n/a
Default LadyBug's Suppertime! - 09-07-2008, 03:57 AM

Hello eveyone! I really need your help in my project. I have an assignment about using array and I got stuck in it for hours.

LadyBug's Suppertime! starts with the LadyBug in the middle of a group of 11 flowers. Your goal is to make the LadyBug fly from flower to flower in a special manner. 8 times the LadyBug will randomly fly to a flower, making sure to only fly to a flower that has not already been “touched” (in other words, don’t let the LadyBug fly to the same flower twice!). The LadyBug will remember her favorite flower: the tallest of the 8 flowers. After flying to the 8 flowers, it will fly back to her favorite (of course, this time the LadyBug does go back to the same flower twice). At all times, you must display how many flowers she has touched so far in a 3D Text above the scene. Since the LadyBug visits 8 different flowers and then goes back to her favorite flower, it should display the number 9.0 at the end of the animation.

The Alice file of my project is included in the attachment of this post. I need help in stopping the bug from flying to the same flower twice and how to choose the tallest flower to fly back.

I have two tips from my teacher in solving this. I hope that they will be useful.

+ If you want to find the tallest object in a group of objects, you do not have to remember all the heights of all the objects. Take this example: if I want to know who the tallest person in the class is, I could ask everyone's height and write it all down on a piece of paper, sort the heights, and then pick the tallest height. In order to do that, you would need an array. But this is too complicated, plus you cannot do that in this assignment because of Alice bugs. In this assignment, you should do the simplest solution: go through the class one by one. Take the first 2 people, and ask "who is the taller between you 2?". Then take the taller, and move on to student #3, and ask these 2 people, "who is the taller between you 2?". Then take the taller, and move on to student #4, and so on and so on. Notice that I don't need to remember the heights of all the students that I've already talked to and decided that they're too short (as soon as I decide that someone is shorter, I can forget that person's height). I only need to look at 2 heights at the same time. That's it, very easy. No need for an array for this. Also, notice that this solution of going one by one between students is very similar to the ladybug flying around going one by one between flowers.

+ How do you remember if you've already visited an object?
Again, let's take the example of students.
If I have an array of objects where each object is a student, how do I track who I have already talked to? Well, I could have a sheet of paper with a list of all the students and after I've visited each student, I can put a checkmark next to the student's name. That way, if I accidentally go back to an old student, I can see on my sheet of paper "oh I've already talked to you, so I will skip you this time." This sheet of paper is like an array! But it's not the same array as the original array of objects. So, use a different array! You can create a new array of type Boolean, object, string (but not number because Alice has a bug with arrays of numbers). Which type is most like a checkmark?
Attached Files
File Type: a2w damn.a2w (704.8 KB, 126 views)
   
Reply With Quote
Checkmarks are true or false
Old
Digimath
Guest
 
Status:
Posts: n/a
Default Checkmarks are true or false - 09-07-2008, 06:14 AM

A checklist is most like a Boolean array. Do you have to use an array? A list might be better than an array since you can remove items from it. Then, only the available objects (flowers) would be in the list. This is the equivalent of a hat that has little pieces of paper in it.
   
Reply With Quote
Reply

Thread Tools
Display Modes

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 ©2020, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.