Luet oppimateriaalin englanninkielistä versiota. Mainitsit kuitenkin taustakyselyssä
osaavasi suomea. Siksi suosittelemme, että käytät suomenkielistä versiota, joka on
testatumpi ja hieman laajempi ja muutenkin mukava.
Suomenkielinen materiaali kyllä esittelee englanninkielisetkin termit. Myös
suomenkielisessä materiaalissa käytetään ohjelmaprojektien koodissa englanninkielisiä
nimiä kurssin alkupään johdantoesimerkkejä lukuunottamatta.
Voit vaihtaa kieltä A+:n valikon yläreunassa olevasta painikkeesta. Tai tästä:
About This Page
Questions Answered: Can I apply what I’ve learned on a larger
Topics: A particular simulator app. There are no new topics per
se, but we will discuss a program that is more complex than any
of the previous ones.
What Will I Do? Program.
Rough Estimate of Workload:? A couple of hours?
Points Available: B40.
Related Projects: Robots (new).
Our virtual robots live in a grid. The robots take turns to act.
Robot actions largely involve moving and turning.
Much of Week 8 revolves around a programming assignment in which you construct a robot
simulator. In this simulator, a “robot world” is essentially a grid where “robots”
of very little brain conduct their virtual existence.
The assignment has been broken down in eight parts. The first two are in this chapter;
the rest are in Chapters 8.2 and 8.3.
Before we get started in earnest, let’s form an overview of the project that you’ll be
The Robots project contains two packages. The classes in o1.robots constitute the
robot simulator’s internal model; o1.robots.gui provides a user interface. The user
interface is ready for use as given and we won’t discuss it further here.
We’ll build the simulator on the same Grid class that you used in Chapter 7.4.
The following table briefly describes each of the simulator’s main components. Below the
table, you’ll find a diagram of the components’ relationships.
Before you go on
Try to get a general sense of the Robots project by reading the description
above and the Scaladocs. Browse the source code, too.
For this question, assume that the project has already been implemented
and works as specified. Also assume that we’ve created a robot world
and a variable testWorld that refers to it. Moreover, we’ve created
two robots and added them to the world. Neither of the two robots has
yet had a turn to act. We now execute the following lines of code:
testWorld.addRobot(GridPos(1, 1), North) // let's say this square is previously empty
Which of the robots has the next turn to act?
Read the claims below and select all the correct ones.
Note: below, the expression “each object knows” means “each object
has stored in its instance variables or can trivially determine with
a simple method call”. This is not a trick question. Its only purpose
is to encourage you to study the Scaladocs and learn about the given
You’ve been given a whole bunch of code, much of which works in principle, but the
program is not ready to run. Eclipse spews a stream of errors.
RobotWorld has been only partially implemented. Fix it:
Use this form to submit your solution to Parts 1 and 2.
A+ presents the exercise submission form here.
The assignment continues in upcoming chapters.
Please note that this section must be completed individually.
Even if you worked on this chapter with a pair, each of you should submit the form separately.
Time spent: (*) Required
Please estimate the total number of minutes you spent on this chapter (reading, assignments,
etc.). You don’t have to be exact, but if you can produce an estimate to within 15 minutes or
half an hour, that would be great.
Written comment or question:
You aren’t required to give written feedback. Nevertheless, please
do ask something, give feedback, or reflect on your learning!
(However, the right place to ask urgent questions about programs
that you’re currently working on isn’t this form but Piazza or the
lab sessions. We can’t guarantee that anyone will even see anything
you type here before the weekly deadline.)
Thousands of students have given feedback that has contributed to this ebook’s design.
Weeks 1 to 13 of the ebook, including the assignments and weekly bulletins, have been
written in Finnish and translated into English by Juha Sorva.
Weeks 14 to 20 are by Otto Seppälä. That part of the ebook isn’t available during the
fall term, but we’ll publish it when it’s time.
The appendices (glossary, Scala reference,
FAQ, etc.) are by Juha Sorva unless otherwise specified on the page.
The automatic assessment of the assignments has been programmed by Riku Autio, Jaakko
Kantojärvi, Teemu Lehtinen, Timi Seppälä, Teemu Sirkiä, and Aleksi Vartiainen.
The illustrations at the top of each chapter, and the similar drawings elsewhere in the
ebook, are the work of Christina Lassheikki.
The animations that detail the execution Scala programs have been designed by Juha Sorva and
Teemu Sirkiä. Teemu Sirkiä and Riku Autio have done the technical implementation, relying on
Teemu’s Jsvee and Kelmu
The other diagrams and interactive presentations in the ebook are by Juha Sorva.
The O1Library software
has been developed by Aleksi Lukkarinen and Juha Sorva. Several of its key components
are built upon Aleksi’s SMCL
The pedagogy of using tools from O1Library (such as Pic) for simple graphical programming
is inspired by the textbooks How to Design Programs by Flatt, Felleisen, Findler, and
Krishnamurthi and Picturing Programs by Stephen Bloch.
The course platform A+ has been created by
Aalto’s LeTech research group and is largely
developed by students. The current lead developer is Jaakko Kantojärvi; many other
students of computer science and information networks are also active on the project.
For O1’s current teaching staff, please see Chapter 1.1.
Additional credits appear at the ends of some chapters.