[General boards] [Winter 2019 courses] [Fall 2018 courses] [Summer 2018 courses] [Older or newer terms]

A2 blowBubble()


The specification says:
Fish and HungryFish should blow a bubble at their location (after moving) about 10% of the time.

Does this mean the bubble is assigned to the coordinates of the Fish before it moved (so that it doesn’t replace the fish)?

The specification is still unclear after viewing testFishBubbles(). The test checks for an instance of Bubble at entities[5-1][10], since the fish is going left and started at entities[5][10]. However, if the fish is going left, its x-coordinate must decrease by 1, so won’t the fish potentially be at entities[5-1][10]? I don’t understand how the code can create a Bubble at entities[5-1][10] without potentially replacing the fish (about 80% of the time, when the fish doesn’t move up or down).


Reasonable ideas might be to spawn the bubble above the fish or to wait a tick and then spawn the bubble where the fish was


Sorry, the specifications are actually clear about this – see Assignment 2 Bubble Query


I’m having the same issue. It seems like the blowbubble method would cause a bubble to be placed in the same array index as the fish and thus would cause the fish to disappear. I was thinking maybe we should place the bubble in front of the fish if possible? As if it was coming out of its mouth, one index in front of it.


I am thinking of the same thing. But wouldn’t the coordinate of bubble be two indices off the original fish coordinate (since the fish has to move one unit left/right first)? Does that violate the specification because even the provided test method only checks for one index off?


I’ve changed the wording of the specification for blowing bubbles – as long as you do something “reasonable”, you’ll be fine regarding this behavior.

Feel free to edit the provided test to actually test the behavior you introduce.


@t6charti You said we are free to edit the provided test to match the behavior in our implementation, as long as it is reasonable. But then, if your implementation of the class is different than mine, and you run my test on your implementation, expecting that the test passes, the test will in fact fail. Considering that part of the marking this assignment is feeding your implementations into my tests and verifying the correctness of my tests, is this not an issue?


The tests we write will be for some reasonable interpretation of the behavior – i.e., bubbles should be spawned somewhere near & above the fish (so manhattan distance 1 of it), but the exact positioning is not tested

The “buggy implementation” we will give will spawn a bubble somewhere wildly wrong, like at a transposed (y,x) pair, and make sure that your test fails – it doesn’t make sense for a fish at (10, 2) to spawn a bubble at (2, 10), so something should fail there.


This is also why we say not to edit the semantics or structure of the public methods – our fish will do something like

if(d < 0.5)
FishTank.addEntity(2, 10, new Bubble())

or something along those lines, so as long as you respect the semantics of the update() and “addEntity” methods, you’ll be fine.


@t6charti Thanks for clarifying. My understanding is that you will run my tests ONLY against your buggy implementations, never against your bug-free implementations. That way, if my test are more restrictive then the specification then it is acceptable, and it would only be a problem if they were less restrictive. Correct?


You are correct! We will test your implementation with our tests, and test your tests with very buggy implementations (that don’t reference any fields or anything)