fix AI bug
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user