Download Problem Solving - SSA Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Multiple-criteria decision analysis wikipedia , lookup

Transcript
Problem Solving
Mr. Haytock
Problem Set #2: The Robots of Hogwarts
For this problem set, complete the following exercises. Note that you must utilize conditionals in
your solutions. Be sure that you include a design in outline or pseudo-code format, make your
solution as efficient as possible, and document your work with descriptive comments. Write a
paragraph of concluding reflections:
 Describe the particular challenges you had with the problem set and how you
resolved them.
 Analyze your solution in regards to efficiency. Count the number of steps your robot
takes to complete the task. Include conditional tests.
 For one of the solutions, explain what you have done to make it readable.
The problem set is due: _________, _______. You may hand it in up until 3 PM before it is
counted late. Hand in your problem set (printouts) to me or to another computer science teacher.
1: Spider Traps
Someone has broken into Hagrid’s garden and
stolen some of the spider traps there. Hermione
must replace the missing traps with new ones.
Construct the robot at (3, 3) with twenty-seven
beepers. The robot should place one beeper on
every location that does not already have a beeper.
The garden is a 3 x 9 area. Run your solution on
the “spider2.kwld” and “spider3.kwld.”
2. Serpent: Karel the PotterBot must collect the
bones of the defeated basilisk and use them in a
potion. Karel begins at (2, 3, East, 0) and must
pick up the trail of bones (beepers) until reaching
the head (at 6, 5). The length of each trail is as
before—the first several are length six, the next
two are length four, and the last two are length
two. The number of bones at each location may
differ, however. At some places there are two or
even three beepers. When you finish your
program, make sure that it works on
“basilisk1.kwld” and “basilisk2.kwld.”
3. Wand: Harry the PotterBot is in a sealed
tunnel and must retrieve its wand so it can
escape. The robot is to be constructed at (5,
5) facing East. The wand is three spaces
away, but it is unclear where because the
tunnel twists in unknown ways. The tunnel
is only four spaces wide, but it may twist to
the left or right at each space. Have the
robot retrieve its wand. Test your solution
on “wand1.kwld,” “wand2.kwld,” and
“wand3.kwld.”
Extra credit:
Harry the PotterBot must navigate a
Quidditch obstacle course on its robobroom. The robot begins at (1, 1, East, 0)
and must get from avenue 1 to avenue 9 (8
steps). At any point, the robot may
encounter a barrier that it must avoid by
switching streets. For instance,
encountering a barrier on street one will
cause it to switch to street 2, and vice versa.
The final location of the robot may be on
either street 1 or street 2. When you finish
your program, make sure that it works on
“quidditch1.kwld” and “quidditch2.kwld.”