-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJogador.py
29 lines (23 loc) · 1.09 KB
/
Jogador.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 BuscaMinimax import BuscaMinimax
class Jogador:
def __init__(self, rede=None):
self.rede = rede
'''
- Jogador Aleatório: executaJogadorAletorio -> Jogadas Aleatórias
- Jogador MiniMax: executaJogadorMiniMax -> Jogadas baseadas no MiniMax
'''
#Função que executa um movimento aleatório dentre os movimentos legais disponíveis
def executaJogadorAleatorio(self, ambiente, tabuleiro, marcacao):
movimentos = list(ambiente.movimentosDisponiveisLegais(tabuleiro))
return random.choice(movimentos)
def executaJogadorMiniMax(self, ambiente, tabuleiro, marcacao):
minimax = BuscaMinimax(ambiente)
resultado = minimax.algoritmoMinimax(ambiente, tabuleiro, marcacao, 4)
movimento = resultado[1]
return movimento
def executaJogadorMiniMaxNN(self, ambiente, tabuleiro, marcacao):
minimax = BuscaMinimax(ambiente, 'MLP', self.rede)
resultado = minimax.algoritmoMinimax(ambiente, tabuleiro, marcacao, 100)
movimento = resultado[1]
return movimento