Due: Thu, 6 Nov 2014, 10pm
70 pts, 7% of total grade.
Write a program to simulate Darwin's World.
Darwin's World contains a two-dimensional grid. Each square in the world can contain at most one creature.
Each creature has a species, a direction, and a program counter.
Each species has a program (a set of instructions).
A creature executes the instruction indicated by the program counter. Each creature is given a turn.
Here's an example of a creature program:
- if_wall 3
- go 0
- go 0
Creatures begin executing at line 0. There are two types of instructions: those which cause an action and those which affect the flow of control. Above, the only action instructions are hop and left. The rest are control instructions.
Darwin gives each Creature a turn in a left-to-right and top-down ordering. During a turn a Creature can execute only one action instruction.
Here are the descriptions of the 9 instructions:
|Action||hop||If the space ahead is empty, move forward, otherwise, do nothing.|
|left||Turn to face left.|
|right||Turn to face right.|
|infect||If the space ahead contains a creature of a different species, change that creature to be of your species, reset the program counter, but leave the direction unchanged, otherwise, do nothing.|
|Control||if_empty n||If the space ahead is empty, go to line n, otherwise, go to the next line.|
|if_wall n||If the space ahead is a wall, go to line n, otherwise, go to the next line.|
|if_random n||Randomly choose between going to line n or the next line. If rand() from <cstdlib> returns an odd number, go to line n. Call srand(0) at the start of every test case that uses rand().|
|if_enemy n||If the space ahead contains a creature of a different species, go to line n, otherwise, go to the next line.|
|go n||Go to line n.|
Create a good OO design by writing well-defined classes that are responsible for a specific and modular part of the solution. Avoid getters, setters, and friends, which are often signs of a bad design:
You must design an interface for the various classes.
The interface should be rich enough to be able to create the best creature without writing any code.
I mean something like this:
Species best; best.addInstruction(...); best.addInstruction(...); ... Creature b1(best, ...); Creature b2(best, ...); ... Darwin x(72, 72); x.addCreature(b1, ...); x.addCreature(b2, ...); ...
Create a UML diagram to represent the design. Use any UML editor that you like. The diagram only needs to show the associations and multiplicity between the classes.
You may not use new, delete, malloc() or free(). You may use the STL.
These are additional descriptions of the underlying math:
- Estimate time to completion.
- Create a private Git repository at GitHub, named cs371p-darwin.
- Add at least 10 of these requirements as issues to the issue tracker at GitHub.
Add at least 10 more issues, one for each bug or feature, both open and closed with a good description and a label.
- Invite the graders to your private code repo.
- Clone your private code repo onto your local directory.
- Make at least 5 commits, one for each bug or feature.
If you cannot describe your changes in a sentence, you are not committing often enough.
Make meaningful commit messages identifying the corresponding issue in the issue tracker (see closing issues via commit messages).
- Write unit tests in TestDarwin.c++ that test corner cases and failure cases until you have at least an average of 3 tests for each method, confirm the expected failures, and add, commit, and push to the private code repo.
- Implement and debug the simplest possible solution in Darwin.h and Darwin.c++ with assertions that check pre-conditions, post-conditions, argument validity, and return-value validity, until all tests pass, and add, commit, and push to the private code repo.
- Clone the public test repo onto your local directory.
It is critical that you clone the public test repo into a different directory than the one you're using for your private code repo.
- Copy your unit tests and your acceptance tests to your clone of the public test repo, rename the files, do a git pull to synchronize your clone, and then add, commit and push to the public test repo.
The files MUST be named EID-RunDarwin.out, EID-TestDarwin.c++, and EID-TestDarwin.out in the public test repo.
- Create the UML diagram.
- Run Doxygen, which will create html/, that then documents the interfaces to your functions.
Create inline comments if you need to explain the why of a particular implementation.
Use a consistent coding convention with good variable names, good indentation, blank lines, and blank spaces.
- Create a log of your commits in Darwin.log.
- Obtain the git SHA with
git rev-parse HEAD
- Fill in the Google Form.
- It is your responsibility to protect your code from the rest of the students in the class. If your code gets out, you are as guilty as the recipient of academic dishonesty.
Requirements for getting a non-zero grade.
- [ 5 pts] GitHub private repo with graders invited as collaborator and a log of the commits.
- [ 5 pts] GitHub issue tracker with issues from requirements and more.
- [15 pts] Well designed OO solution with assertions that check pre-conditions, post-conditions, argument validity, and return-value validity.
- [15 pts] At least an average of 3 tests per method with good coverage in the public test repo with the precise naming of the files.
- [15 pts] Acceptance tests in the public test repo with the precise naming of the files.
- [ 5 pts] UML diagram.
- [ 5 pts] Doxygen documentation.
- [ 5 pts] Google Form with time estimate.
Private Code Repo Files
Place the following files, with these exact names, directly in cs371p-darwin, no subfolders:
- RunDarwin.c++ (do not run gcov, do not run valgrind)
- RunDarwin.out (no gcov output, no valgrind output)
- TestDarwin.c++ (average of of at least 3 unit tests per method, run gcov, run valgrind)
- TestDarwin.out (include gcov output, include valgrind output)
- Darwin.pdf (UML diagram)
- html/ (output of Doxygen)
- Darwin.log (output of git log)
- gitignore.txt (rename .gitignore, for your use only, no need to submit)
- makefile (for your use only, no need to submit)
Public Test Repo Files
Place the following files, with these exact names, directly in cs371p-fall-2014/darwin-tests/, no subfolders:
- EID-RunDarwin.out (no gcov output, no valgrind output)
- EID-TestDarwin.c++ ((at least an average of 3 tests per method, run gcov, run valgrind)
- EID-TestDarwin.out (include gcov output, include valgrind output)
- Atlassian Git Tutorials
- Git Cheat Sheet
- Git Generating SSH Keys
- Git Guides
- Git Immersion
- Git Reference
- GitHub Guides
- Google C++ Style Guide
- Try GitHub
|Name||GitHub ID||GitHub Test Repository||Google Form|
|Henry Chen||chukhinhenry||darwin-tests||Google Form|