示例#1
0
def exempleIA(IA,team1, team2, it, ip):
    match = SoccerMatch(team1,team2)
    #on reinitisalise fichier
    a = open("Match","w")
    a.close()
    match.play()
    match.save("Match")
    Monte_Carlo("Match","action",it,ip,IA.dico)
    a = open("action","w")
    a.close()
示例#2
0
def joue_IA(IA,teamIA, teamAdv,it, ip):
    #si le fichier d'action n'est pas vide on apprend
    if os.path.getsize("action") != 0:
        Monte_Carlo("Match","action",it,ip,IA.dico)
        #on supprime les anciennes actions
        a = open("action","w")
        a.close()
    match = SoccerMatch(teamIA, teamAdv)
    #on reinitisalise fichier
    a = open("Match","w")
    a.close()
    match.play()
    match.save("Match")
示例#3
0
def affiche_joue_IA(IA,teamIA, teamAdv,it, ip):
    #si le fichier d'action n'est pas vide on apprend
    if os.path.getsize("action") != 0:
        Monte_Carlo("Match","action",it,ip,IA.dico)
        #on supprime les anciennes actions
        a = open("action","w")
        a.close()
    match = SoccerMatch(teamIA, teamAdv)
    a = open("Match","w")
    a.close()
    match.play()
    soccersimulator.show(match)
    match.save("Match")
示例#4
0
# nom et strategie du premier joueur
print team1.player_name(0), team1.strategy(0)

joueur1 = Player("Joueur 2", BaseStrategy("fonceetshoot"))
joueur2 = Player("Goal 2", BaseStrategy("defenseduGoal"))
print joueur1.name, joueur2.strategy, joueur2.name, joueur2.strategy
team2 = SoccerTeam("Equipe 2", [Joueur 2, Goal 2])
# nombre de joueurs de l equipe
print team1.nb_players
# renvoie la liste des noms, la liste des strategies
print team1.players_name, team1.strategies
# nom et strategie du premier joueur
print team1.player_name(0), team1.strategy(0)

#Creer un match entre 2 equipes et de duree 2000 pas
match = SoccerMatch(team1, team2, 2000)
#Jouer le match (sans le visualiser)
match.play()
#Jouer le match en le visualisant
show(match)
#Attention !! une fois le match joue, la fonction play() permet de faire jouer le replay
# mais pas de relancer le match !!!
# Pour regarder le replay d un match
show(match)
# Pour sauvegarder un match
match.save("fichier")
# Pour charger un match
match = SoccerMatch.load("fichier")
# Pour reinitialiser un match
match.reset()
示例#5
0

D1= [d1,d2,d3,d4,d5]
D2= [d5,d4,d3,d2,d1]

Liste = []
Liste.append(team1)
Liste.append(team2)
Liste.append(team3)
Liste.append(team4)
Liste.append(team5)
Liste.append(team6)

ListeT = []
ListeT.append(duo1)
ListeT.append(duo2)
ListeT.append(duo3)
ListeT.append(duo4)
ListeT.append(duo5)
ListeT.append(duo6)

if __name__ == "__main__":
    init_fichier(team1,team2)
    #exemple_tournoi(IA,L1,Liste,1,0,10)
    tournoi_IA(IA,teamIAD,ListeT,1,0,10,False)
    #affiche_joue_IA(IA,teamIA,team5,1,0)
    M = SoccerMatch(teamIAD, duo1)
    M.play()
    soccersimulator.show(M)
    enregistre_dico(IA.dico,"dico_apprentissage")