-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_ai.py
29 lines (22 loc) · 843 Bytes
/
basic_ai.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import random
from model import Board
"""
Basic AI : Take a list that contains all the possible move and reduce it at each play
"""
class basic_ai:
def __init__(self, board):
self.board = board
self.moves = []
self.reset()
#print("Possibles moves ({}) : {}".format(len(moves), moves))
def reset(self):
self.moves = self.board.all_moves()
def next_move(self):
if self.board.is_win() == False and self.board.is_loose() == False:
move = random.choice(self.moves)
# move = self.moves[0]
if self.board.is_move_allowed(move):
self.board.play(move)
self.moves.remove(move)
self.moves = self.board.reduce_moves(self.moves)
#print("Possibles moves ({}) : {}".format(len(moves), moves))