I'm trying to create battleship using python and I'm trying to make sure that the ships don't overlap but for some reason when I try and do so noting happens; I think my while loop is wrong. Could someone help me identify the problem. I've attached my code to the post.
Thank you very much
In the while loop, line 31.
You change the values of x and y, but you do not change the value assigned to check 1 and 2. So. Simple add:
check_1 = warmap[x+1][y] check_2 = warmap[x][y+1]
So, your while loop should look like:
while check_1!="0" or check_2!="0": x=random.randrange(0,6) y=random.randrange(0,6) # Reassign check_1 = warmap[x+1][y] check_2 = warmap[x][y+1]