140 likes | 156 Views
Explore a challenging problem-solving case study in Alice - Create a scene with 3 animals, resize them, find the tallest, and sort them. Learn methods, functions, and techniques. Discuss different ways to solve complex problems.
E N D
CS320n –Visual Programming Problem Solving Case Study (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
What We Will Do Today • Look at a complicated problem • Discuss different ways of solving it • Learn some techniques in Alice • Practice Writing methods and functions Problem Solving Case Study
Problem to Solve • Create a scene with 3 animals standing in a row • resize each of them from 0.5 to 3 times its original size • Find the animal that is tallest and spin it once to the right and once to the left • Sort the animals by their height smallest on the camera’s left, tallest on the camera’s right • Display message “In order” any time the animals are sorted Problem Solving Case Study
Objects in the World • Animals – Penguin, Joey, White Rabbit • careful to pick animals whose center point is at their feet • challenging if center point is higher • position animals 1 meter apart (use move to and move methods in set up) • Need some way to track position • fixed objects (balls) • 3D text “In Order!” in scene but invisible Problem Solving Case Study
Initial Scene tennis ball is position 1, toy ball is position 2, volleyball is position 3 Use these as fixed points of reference Problem Solving Case Study
Storyboard • check if animals are sorted • resize animals • check if animals are sorted • make tallest spin • sort animals • display in order (assuming sorted) Problem Solving Case Study
world.my first method Problem Solving Case Study
make Tallest Animal Spin Around • find out which is tallest • spin it around right, then spin it around left • create a function to determine which of the three things is tallest Problem Solving Case Study
tallest Of Three • How do we do this? • It’s not so bad for 3 but if there were more it would become too complicated Problem Solving Case Study
check If Sorted By Height • How do we check if items are sorted by increasing height? • Check if object in position 1 is shorter than object in position 2 and if object in position 2 is shorter than object in position 3? • How do we know which animal is in which position? Problem Solving Case Study
which Object Is Closest To Problem Solving Case Study
sort Animals By Height • How? • More than one way? • Again, if we get more than 3 becomes very complicated, very quickly Problem Solving Case Study
One Way • determine which thing is in which position • determine which thing is tallest • if tallest is not in position 3, swap tallest with thing in position 3 • then check if the thing in position 2 is taller than the thing in position 1 • if not then swap those 2 • animals next to each other started out 1.5 meters apart • or could use distance to the left / right function Problem Solving Case Study