Friday, 8 March 2013

Project 1

This entire week I've been working on the first project. As I've said before, the project was a very interesting assignment. I liked working on it, especially on the ball. One reason for this might be that I completed the ball fairly easily and with no problems. I got it to bounce around and respond to key presses without encountering any major problems.
I am however having a problem with the ecosystem. The problem seems to be at the function to update the ecosystem. I have written the function as described by the expression, however the problem is that the ecosystem only seems to update once, and not repeatedly every second as it should. I have seen on Piazza that many other students are encountering the same problem. So far I have not been able to come up with a solution, even though I have tried to write the update function in different ways. The end result seems to be the same, the ecosystem updates once, then stops and DrRacket happily tells me that all the tests have passed. It is quite puzzling. The first update seems to be accurate, but everything stops after that. I am not ruling out that it might be a problem with my DrRacket or my computer somehow, although in the case of the bouncing ball everything seemed fine. I also double-checked the big-bang code and everything seems to be fine with that.
Everything I've tried so far does not seem to work. I am confident all my codes are correct (DrRacket at least approves to this to some extent when it comes to the check-expects) but I am at a loss to explain what might be causing this defect. I will for now keep trying, but I feel I am running out of options.
UPDATE
I have finally figured it out, and yes, it was a problem with my codes. My initial code for the update used the MICE-START and FOXES-START number as the number of the mice and foxes in the ecosystem. For some reason, I had decided that the (ecosystem-foxes and mice eco) was unneeded. I was thinking, DrRacket is doing the initial update as it is supposed to. So then why does it not keep updating the ecosystem? The problem of course was that MICE-START and FOXES-START were just two numbers, the initial numbers. DrRacket should do an update after 1 second, and then whatever number comes up for both foxes and mice has to be the new number of mice and foxes in the ecosystem. DrRactket then feeds this number into the next update, does the calculations again and so it goes on. Using FOXES-START and MICE-START was really disingenuous in this way, because those numbers do not update. They are just the initial numbers, so DrRacket was not updating just once, but when it was feeding the FOXES-START and MICE-START numbers back to the update function nothing was changing. DrRacket was then updating every second, but the update was similar to the one before. That got me thinking there has to be another way of doing this, these numbers are just the start numbers, they are not the number of foxes and mice in the ecosystem at any given moment. So I went back and downloaded the starter code again which reminded me of the the (ecosystem-foxes eco) and (ecosystem-mice eco) that I had previously deleted, and that's when the light-bulb came on. I just switched those in place of FOXES and MICE-START in my code and now everything works. Finally.

No comments:

Post a Comment