Hi everyone! I'm having trouble making Part 3 of game_of_life_template.py program work. Is it possible for any of you to view my code and tell me where I'm going wrong?
Post your code on pastebin.com and provide a link, I can try and help you out.
Awesome. Will do!
Here you go: http://pastebin.com/vWY0eyuR I suggest paying attention to my code defining the get_block_neighbors method, since that's the method that isn't passing the test. I get the message: "FAIL: get_block_neighbors() should NOT return new Blocks!" However, I've checked to see whether or not I'm creating new blocks by printing out the blocks in the get_block_neighbors method and the blocks in self.block_list. Blocks with the same "square coordinates" print out the same number at the end of something like "<__main__.Block instance at 0x0000000002AA0148>" I'm assuming that means I'm dealing with same blocks. Also, forgive me if the code is hard to read. Many of the comments littered around were used for debugging purposes. I hope that doesn't cause much confusion.
Silly question: Why all the bother to create alive_neighbors and then return neighboring_blocks, ( which was also declared in the method's scope ) ?
Oh, hey. Not silly question :) I created it before I realized we only need to return a list of neighbors and not the ones that are alive as well. I forgot to comment it out.
Join our real-time social learning platform and learn together with your friends!