fix AI bug

This commit is contained in:
2022-04-25 17:41:57 -07:00
parent 7f6a01e2fb
commit 335836b03e

View File

@@ -60,7 +60,9 @@ class AIPlayer(Player):
def guess(self, opponent: Player) -> Coordinate: def guess(self, opponent: Player) -> Coordinate:
for guess in self.guesses: for guess in self.guesses:
if self.coord_status(guess, opponent) == CoordStatus.HIT: if self.coord_status(guess, opponent) == CoordStatus.HIT:
return self.guess_near(guess, opponent) candidate = self.guess_near(guess, opponent)
if candidate:
return candidate
while True: while True:
guess = random.choice(opponent.board.columns), random.choice(opponent.board.rows) guess = random.choice(opponent.board.columns), random.choice(opponent.board.rows)