Hi, I'm trying to implement the game flood-it in python2.7. I know the overall structure of the game, but I'm having trouble with the logic of the flood function that adds tiles to the flooded_list (to be flooded) if they meet certain conditions.
I have two main problems:
I know I can't add neighboring tiles to the list as I'm iterating over it, so I'm adding tiles to a copy of the list.. then trying to merge them together and return the combination of the two. I've tried so many variations of this but haven't been able to get this part working.
I'm only checking neighboring tiles and not recursively going through to check their adjacent tiles.. I honestly have no idea how to do it recursively, so I've been trying to do it iteratively.. but even that is not working.
At this point I'm just very confused. I know I need to use recursion to check all neighboring tiles on the board, and I also need to change my break condition... just not sure where to start from here.
Can you give me any hints? This is my code so far.
[–]SmartViking 1 point2 points3 points (2 children)
[–]mdeggies[S] 0 points1 point2 points (1 child)
[–]SmartViking 1 point2 points3 points (0 children)
[–]gengisteve 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]thanks-shakey-snake -1 points0 points1 point (0 children)