othello / ai.py
Renecto's picture
Create ai.py
a2ba12e verified
raw
history blame
416 Bytes
# ai.py
import random
from app import get_flips, apply_move
def choose_move(board, player):
"""
Simple AI: chooses a random valid move from all legal flips.
"""
valid_moves = []
for r in range(8):
for c in range(8):
if get_flips(board, r, c, player):
valid_moves.append((r, c))
if not valid_moves:
return None
return random.choice(valid_moves)