Getting Started
This is assignment is a followup to L11, L12, and L13. It is based a project from Chapter 7 of Eloquent JavaScript{2ed}. You can read more about the implementation there. I have converted the older style code to use ES2015 classes.
Start with the following the following JavaScript code, save it to
~fcshome/cs2613/assignments/A4
. Save the .spec.js
files in
~fcshome/cs2613/assignments/A4/spec
- life.js Core classes for "Electronic Life"
- life.spec.js tests for the above
- moarlife.js new code for this assignment (from the book)
- moarlife.spec.js tests for the above
- valley.js animation. run with "node valley.js"
Since your assignment will involve modifying an existing codebase, make sure that your git commits reflect a logical sequence of changes.
Update the tests to provide full line and branch coverage, according to
nyc jasmine
. In my solution this involves adding 4 tests.Make an
ExplodingBunnyRabbit
class based onPlantEater
that explode if they eat too much. More precisely, if their energy exceeds 55, theiract
method should return an action of type "die" 25% of the time; otherwise it should behave like aPlantEater
. For full credit, useextends
.Add tests for
ExplodingBunnyRabbit
similar to those ofPlantEater
. Copy and paste is OK here, although you'll need to make some changes.Initially the 'die' returned by the
ExplodingBunnyRabbit
is ignored. Update actionTypes so that the 'die' event is handled by replacing the current rabbit with a piece of wall. As a hint, you'll have to somehow make sure you get the right 'originChar' for the new piece of wall.Update your tests for complete coverage.