COMPUTER SCIENCE #3
This
week has got to have been one of the hardest since the beginning of the year.
Although it was quite difficult trying to remember all the different terms
during the first few weeks, project one was far beyond just memorization and my
group found themselves staring at the computer screen, knowing that something
was wrong not completely understanding how to identify it.
The check expect wasn’t as difficult because it requires simple substitution of
numbers or letters.
EX: (define (x-five num) (* 5 num))
The following exemplar is an example of a definition or function that can be
put into Dr. Racket. The expected value for when you plug in 6 for “num” would
be 30. This expected value is 30 because you’ve defined (x-five num) to be
(5 x num). Thus, when you check the
expected result, you’d replace all the “num” placeholders with your desired num
(in this case, it would be 6) and receive your desired result.
EX: (check-expect (x-five 6) (*5 6))
This tool is quite useful because it allows you to instinctively ensure that
your function works and will yield your desired result. This check-expect can
be done backwards by writing a function or definition based off of what you’d
expect by replacing the numbers by a single variable or placeholder. So, if you
were given:
EX: (check-expect (x-six 5) (*6 5))
(check-expect (x-six 7) (*6 7))
You would be able to work backwards by looking at the constant variables (in
this case it’s x-six and 6). Then you’d replace the changing numbers (in this
case it’s 5 and 7) with a placeholder like “num”. This would give you
EX: (define (x-six num) (*6 num))
However, the problem did not lie with the examples above, but rather with the
integral make-ecosystem function. My partner and I, having read the
instructions and handouts, quickly inserted what we thought was the right
input.
(- (* MOUSE-BIRTH-RATE MICE-START) (* FOX-MOUSE-MEAL-RATE MICE-START
FOXES-START)) (ecosystem-mice eco))
(- (*FOX-MOUSE-EAT-BREED-RATE MICE-START FOXES-START) (* FOX-DEATH-RATE
FOXES-START))
(ecosystem-foxes eco))
However, as one might quickly guess, we were wrong. What had started as a
seemingly easy question quickly became a confusing composition of functions. What
we found Dr. Racket yielded when we pressed “Run” was two scaled images, the
fox and the mouse, not moving. We looked back at the failed function. What had
we done wrong?
Looking back to the handout, re-reading the hints, and looking back at the
function, we couldn’t figure it out. Thus, we went back to the function, looked
at each input to see each individual significance; we did this by using the “Step”
button on Dr. Racket. At this moment, I
really understood the importance of knowing what each unit meant. It was
through this process of looking back at each input of Dr. Racket did we realize
that we had skipped over the function that had already contained the rates of
births and deaths. We realized that the defined functions of new-mice, new-foxes,
dead-foxes and eaten-mice were not just there for check-expects, but rather it
was to play an integral part in constructing the whole ecosystem. We suddenly
felt a huge wave of relief as we thought we had figured out our problem.
However, after we quickly placed our discovery back into the equation, we realized
once more that our function was still not correct. The same picture of the
stagnant fox and mouse looked at us through the computer screen.
After we slaved over the keyboard and was still unsuccessful, we sought help
from people with more experience and wisdom. We went to the aid center.
One of the T.A’s despite his own lack of experience with Dr.Racket, provided us
with valuable help and priceless guidance. He went over each step of the
ecosystem function with us and together, we interpreted what each input meant.
Things such as (define-struct ecosystem (mice foxes)) became clearer and by
looking back at Dr. Heap’s videos for the quiz, our minds to computer science
were opened once more.
By looking at each part, reading the question and realizing that this was a
cyclical rather than a numeral question, my partner and I quickly understood
our mistake. What we had inserted before was a number rather than a function.
The MICE-START and FOXES-START was a constant rather than a function and thus
what we needed to find was the right function. What we needed to find was a
function in which the ecosystem could run its calculations not calculation.
Taking a few steps back and recognizing that what we should be inserting was
(ecosystem-mice eco) and (ecosystem-foxes eco), we quickly placed that into the
equation and discovered that once more, our sorrows were had not ended.
The fox and mouse, now tormenting us, appeared on the screen and after
time-consuming deliberation, we sought help from the one man we knew couldn’t
let us down. We went to Mr. Heap himself. After being invited and thoroughly
helped by our teacher, we realized that what we had been missing from our
almost perfect equation was a single number. We had to make the population of
mice smaller.
After changing the population, with our breaths held and our fingers crossed,
we ran our function once more. To our joy, the fox began to grow larger while
the mouse drew smaller and then vice-versa. Our function was finally a success!
I guess what I really wanted to highlight from this whole anecdote is the fact
that sometimes, the best thing to do is to ask for help. As Mr. Heap had told
us before, the best method to problem solve is to identify the problem, think
of possible solutions, take action and then reflect. Giving up after an obstacle
never solves anything. In addition, the
gratitude and pleasure of solving a problem exceeds all hardships previously
experienced. Thus, if after identifying the problem and taking action) re-reading
your notes, looking back at the handout numerous times and trying to toggle functions
around) doesn’t work, the help from those who have much more experience is the
best resource.
From one amateur computer science student to the rest, when all else fails, the
teacher never will (well...usually they don’t).
Sounds like the ecosystem was quite a journey. I'm glad it finally worked out
ReplyDeletewow what a thought process! I also found it really interesting to analyze the functions and really know what each meant. Good job on figuring everything out :)
ReplyDelete-Danii