-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·65 lines (50 loc) · 2.03 KB
/
main.py
File metadata and controls
executable file
·65 lines (50 loc) · 2.03 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import time
from regras_jogo import construir_jogo
from agentes import construir_agente
def ler_tempo(em_turnos=False):
""" Se o jogo for em turnos, passe 1 (rodada), senão se o jogo for
continuo ou estratégico, precisa.
"""
return 1 if em_turnos else time.time()
tipos_agentes = ['Agente_Humano',
'Agente_Amplitude',
'Agente_Profundidade',
'Agente_Aprofundamento_Iterativo',
'Agente_Gulosa_Com_Retrocesso',
'Agente_A_Estrela',
]
def ler_tipo_agente():
print("Escolha um dos tipos de agente: ")
for i in range(0,len(tipos_agentes)):
print("{}. {}.".format(i, tipos_agentes[i]))
input_tipo_agente = int(input("Codigo: "))
return tipos_agentes[input_tipo_agente]
def iniciar_jogo():
# Inicializar e configurar jogo
jogo = construir_jogo()
# Escolher o agente
tipo_agente = ler_tipo_agente()
#tipo_agente = 'Agente_A_Estrela'
print("Vc escolheu o", tipo_agente)
jogador = construir_agente(tipo_agente.upper())
id_jogador = jogo.registrarAgenteJogador(jogador)
tempo_de_jogo = 0
jogo.iniciaJogo()
"""Game loop principal."""
while not jogo.isFim():
# Mostrar mundo ao jogador
ambiente_perceptivel = jogo.gerarCampoVisao() #Matriz aqui
jogador.adquirirPercepcao(ambiente_perceptivel, jogo) #Gera estados aqui
time.sleep(0.5)
#input("Aperte enter para continuar.")
print(" ")
# Decidir jogada e apresentar ao jogo
acao = jogador.escolherProximaAcao()
#print("Proxima ação: " + acao)
jogo.registrarProximaAcao(id_jogador, acao)
# Atualizar jogo
tempo_corrente = ler_tempo()
jogo.atualizarEstado(tempo_corrente - tempo_de_jogo)
tempo_de_jogo += tempo_corrente
if __name__ == '__main__':
iniciar_jogo()