Assignment 2 -- Robot-Garden at the dept of Computing Science

The report should be handed in before Monday May 14:th, at 15.00 o'clock. It should be a full report on paper according to the specifications.

You are an assistant at one of the more prominent departments of the University, and your ambition is to initiate a robotics project. To demonstrate the good of robotics research at the department, and also to show that 'this is the place to be', you decide to write a simulation program with a lot of small robots running around and displaying different behaviours. Furthermore, you decide to implement two different kinds of robot:

Light-lovers, that steers towards the light
Light-haters, that shy away from light

The robots also get more and more hungry as time passes.

In the robot-world there are one or more light-sources, and one or more food-places. When a hungry robot makes it to a food-place it eats and gets full. The hunger can apparently grow so big that it overcomes the fear/love of light.

To be able to test your theories you decide that the robots live in a garden of squares. A square can hold one robot at a time, but it can also be occupied by a light-source or a food-place. The simulation could loop trough all robots one at a time and find out if they can move. Which way they move depends on the distance to the lights and the food and also on how hungry the robot is. You also have to avoid collisions with other robots and prevent any robot from moving outside the garden.When all robots have had the opportunity to move (they can only move one step at a time in eight directions) the program should display the garden on the screen, and then it is time for another round. You also realize that it would be a nice feature if the garden could be saved on a file and then loaded in at a later time.

Task:

Design and implement a simulation program that works along these lines. A suitable size of the garden might be 20 x 40 squares, with a couple of lights and food-places, and a hundred robots or so (its up to you do decide what suits your simulation). You might place the robots etc. randomly or let the user put them in specific places. You can use any graphics output you like, from ordinary character graphics i a DOS-window to full Windows graphics. The method you choose has no impact on your grade, any form of graphical representation is fine.

Consider carefully how you should model the garden and the robots (since data representation is 'half the work'), who should inherit whom and how to implement the different properties of your robots and other things in your garden. You are free to add any extra classes that you might need or find interesting.

Draw a class diagram of your system.

Some suggestions:

It might be a good idea to look at the distance from the robot to the lights and the food and somehow weigh hunger versus light love/hate. Feel free to eperiment with different functions for the attraction, but the robots does not have to express any 'intelleigent' behaviour at all.

In object-orineted system it is a central idea that the object itself perform all actions, for example display itself on the screen or save itself to a file. This is a different way of looking at the problem than with 'ordinary' program development and takes some time to get used to, but try to spend some time considering how to get your robots as independent as possible. Note that we do not accept a' non-OO solution' like a matrix with integers that represents robots, and a central main program that makes all decisions. A matrix might be a good solution for keeping track of the robots but in that case it must contain robot-objects or pointers to them. The robots should be as independent as possible and the main part of the code should be in the robot class(es). Avoid a large main program that handles the simulation. Some functionality might have to be in the garden instead of the robots, but that has to be restricted to information about the location of other robots, lights etc.

And as usual: No public attributes and no global variables !