hi i have another problem about a program i'm doing recently:
our teacher instructed us to create a program that simulates drunk snail, which moves to places randomly. Also we have to make the program so that it'll do a self-avoid walk, which means that the snail can't go back to the spot where it already had been. So i constructed a program that does random walk, but i can't get the self avoid walk thingie to work. My method's writing all the coordinates to a .txt file and use two variables to check the x-coordinate and the y-coordinate of where the snail had been. if i find a match, the program would go back and reproduce another two random number for x and y coordinate, but i can't get it to work. It still steps on the spot it had already been, the source code is here, please help me, i have absolutely no idea why its not working. I've tried so many ways, and it still doesn't work, maybe I forgot to do something or i did something wrong, but i just can't figure out what is it...
thank you for any suggestions to make the program work
our teacher instructed us to create a program that simulates drunk snail, which moves to places randomly. Also we have to make the program so that it'll do a self-avoid walk, which means that the snail can't go back to the spot where it already had been. So i constructed a program that does random walk, but i can't get the self avoid walk thingie to work. My method's writing all the coordinates to a .txt file and use two variables to check the x-coordinate and the y-coordinate of where the snail had been. if i find a match, the program would go back and reproduce another two random number for x and y coordinate, but i can't get it to work. It still steps on the spot it had already been, the source code is here, please help me, i have absolutely no idea why its not working. I've tried so many ways, and it still doesn't work, maybe I forgot to do something or i did something wrong, but i just can't figure out what is it...
thank you for any suggestions to make the program work