0

[Solved] Random numbers keep generating

This is my edited (classified, heh) version of Codecademy's Battleship! tutorial. The problem is, I can't figure out why the ship doesn't sink when you enter the row and column. The randomizer for the position keeps randomizing. It worked before I added classes, and now... https://code.sololearn.com/c71mvn5Qb11t/?ref=app

16th Nov 2020, 11:39 PM
Kelly H. Milligan
Kelly H. Milligan - avatar
2 Réponses
+ 1
Change test condition to this: if guess_row == self.ship_row and guess_col == self.ship_col: You were repositioning the ship with every guess. There are some other issues with your code like inconsistent use of mat/board, but with that fix it should work
17th Nov 2020, 12:48 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
Benjamin Jürgens, thanks! It no longer repositioning, though I do, as you said, have other issues to work out. =)
17th Nov 2020, 3:34 AM
Kelly H. Milligan
Kelly H. Milligan - avatar