Assignment 1, CSC 101

due January 15, 11:59pm

This assignment is the first step in creating your virtual world. The first major tasks are to determine a theme and to specify the inhabitants of your virtual world. As such, part of this assignment can, and probably should, be done away from the computer. This is an opportunity to be creative; there are few restrictions on what may inhabit your virtual world.

For the technical side of this first assignment you will define data representations for some of the entities in your virtual world. These will be used (with modifications) for the remainder of the course project.

Files

Create a hw1 directory in which to develop your solution.

You will submit a text file listing the members of your partnership pair (or a message stating that you will not be working with a partner). This file should be named partners.txt.

You will submit a description of your virtual world in a file saved as a plaintext document (named world.txt) or as a pdf document (named world.pdf).

You will develop your program solution over two files (one for the representations and the other for the test cases). You must use the specified names for your files.

World Description

Write a few paragraphs describing your virtual world and its inhabitants. Be sure to clearly discuss the behavior of each inhabitant and the interactions between the inhabitants. In particular, give details at least one gatherer (e.g., what the gatherer is seeking and what the gatherer does once the object is found), at least one generator (e.g., what does the generator produce), and at least one resource.

Although, your world can be set anywhere, for both the logic and 'drawing' of these worlds, each one will ultimately be represented as a 2D world - you may want to keep this in mind when designing your world. For example, if you are thinking of a sky world, it will be viewed and programmed as a slice of the sky without depth. In addition, all worlds at some point will need to have some fixed obstacles - again you can be creative - these can be rocks, trees or even dense clouds - but all worlds will at some point this quarter include fixed objects that must be navigated around.

Take the time necessary to give this part of the assignment serious consideration. Do not artificially restrict your creativity for fear of committing to doing too much; we will help guide you to a project that can be completed.

Data Definitions

For this first part of the course project you will define a two-dimensional point, two entities, and one resource. Add a class declaration for each of the following to entities.py.

Point

Declare a class to represent two-dimensional points, named Point. This class must declare an __init__ method that initializes an x and a y field (taken as arguments in this order).

Gatherer

Declare a class for the gatherer entity that inhabits your virtual world. The class should be given a descriptive name (e.g., Bee, RecyclingTruck, MailCarrier). This class must, for this assignment, initialize fields representing the gatherer's name, resource_limit (the maximum number of the gatherer's resource that can be carried), and position (a Point). The initial values of these fields are taken as arguments to the class's __init__ method in the same order just listed. The __init__ method must also initialize the resource_count (the current number of the gatherer's resource carried) field to 0.

Again, be creative. A gatherer can be anything (e.g., a mailman, a submarine, a fairy), but the gatherer must be able to move in your world to gather resources that are spread about. Movement will introduce some of the more interesting computer science challenges this quarter.

Generator

Declare a class for the generator entity that inhabits your virtual world. The class should be given a descriptive name (e.g., Flower, RecyclingBin, Mailbox). This class must, for this assignment, initialize fields representing the generator's name, rate (the generator's resource production rate expressed as number of milliseconds taken to produce a resource), and position (a Point). The initial values of these fields are taken as arguments to the class's __init__ method in the same order just listed.

Unlike the gatherer, your generator, may stay fixed in one location. It is assumed that the generator will generate resources within some reasonable distance from its current location.

Resource

Declare a class for the resource generated and gathered in your virtual world. This class should be given a descriptive name (e.g., Pollen, Plastic, Letter). This class must, for this assignment, initialize fields representing the resource's name, and position. The initial values for these fields are taken as arguments to the class's __init__ method in the same order just listed.

Test Cases

Many people tend to focus on writing code as the singular activity of a programmer, but testing is one of the most important tasks that one can perform while programming. Proper testing provides a degree of confidence in your solution. During testing you will likely discover and then fix bugs (i.e., debug). Writing high quality test cases can greatly simplify the tasks of both finding and fixing bugs and, as such, will actually save you time during development.

In entities_tests.py, write two test cases for each class declared in entities.py. Each test will consist of creating an new instance of the corresponding class and checking that every field has the expected value (these specific tests are of the sort that check for typos).

Your test cases must use the unittest framework introduced during lab and the main testing function should be invoked (as in lab) by the "main" body of code. (Note that each test for a class should be in a separate testing function.)

Again, you must provide at least two separate test cases for each class. But you are welcome to provide more.

Handin

You must submit your solution on unix11.csc.calpoly.edu (or on unix12, unix13, or unix14) by 11:59pm on the due date.

Note that you can resubmit your files as often as you'd like prior to the deadline. Each subsequent submission will replace files of the same name.

Grading

The grading breakdown for this assignment is as follows.