-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathothello.py
More file actions
71 lines (64 loc) · 2.12 KB
/
othello.py
File metadata and controls
71 lines (64 loc) · 2.12 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
66
67
68
69
70
71
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 14 13:55:55 2022
"""
from play import Partie
import matplotlib.pyplot as plt
class Manager:
def menu(self):
print("========== Othello version 3 ========")
print("a) Mode JvsJ")
print("b) Vs AI")
print("c) Mode auto AI vs AI (random vs random)")
print("d) Simulation AI vs AI")
choix=input('Choix : ')
if choix =='a':
partie=Partie(2)
partie.partie()
elif choix =='b':
AI_type = self.subMenuVsOrdi()
partie=Partie(1,AI_type)
partie.partie()
elif choix =='c':
AI_1=self.subMenuVsOrdi()
AI_2=self.subMenuVsOrdi()
partie=Partie(0,(AI_1,AI_2))
partie.partie()
elif choix=='d':
nb_simul=int(input("Nombre de simulations: "))
AI_1=self.subMenuVsOrdi()
AI_2=self.subMenuVsOrdi()
self.simulationAiVsAi(nb_simul,AI_1,AI_2)
else:
exit()
def subMenuVsOrdi(self):
print("============ Ordinateur ==========")
print("Choisir une difficulée d'algorythme:")
print("a) Meilleur Choix_v1")
print("b) Choix aléatoire (par defaut)")
choix=input('Choix : ')
AI_type="random"
if choix =='a':
AI_type="v1"
elif choix=='b':
AI_type="random"
return AI_type
def simulationAiVsAi(self,nb_simul,AI_1,AI_2):
score_AI_1=0
score_AI_2=0
middle=round(nb_simul/2)
for i in range(0,middle):
partie=Partie(0,(AI_1,AI_2))
s_1,s_2=partie.partie(True)
score_AI_1 += s_1
score_AI_2 += s_2
for i in range(middle,nb_simul):
partie=Partie(0,(AI_1,AI_2))
s_1,s_2=partie.partie(True)
score_AI_1 += s_1
score_AI_2 += s_2
print(f"Pour l'algo {AI_1} : score moyen {score_AI_1/nb_simul}")
print(f"Pour l'algo {AI_2} : score moyen {score_AI_2/nb_simul}")
manager=Manager()
manager.menu()