Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,24 @@ app = Flask(__name__)
|
|
24 |
# --- Configuration de la clé secrète ---
|
25 |
IS_DEBUG_MODE = True # Forcer le mode debug pour le développement local
|
26 |
# Pour la production, gérez FLASK_DEBUG et FLASK_SECRET_KEY via les variables d'environnement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
if IS_DEBUG_MODE:
|
29 |
app.secret_key = 'dev_secret_key_pour_eviter_perte_session_rechargement_et_tests_v3' # Changez si besoin
|
@@ -83,7 +101,10 @@ def get_stockfish_engine():
|
|
83 |
app.logger.error("Exécutable Stockfish non disponible. L'IA ne peut pas démarrer.")
|
84 |
return None
|
85 |
try:
|
86 |
-
engine = Stockfish(path=STOCKFISH_EXECUTABLE_PATH_GLOBAL, depth=15, parameters={"Threads": 1, "Hash": 64})
|
|
|
|
|
|
|
87 |
if engine._stockfish.poll() is not None:
|
88 |
app.logger.error("Le processus Stockfish s'est terminé de manière inattendue lors de l'initialisation.")
|
89 |
raise StockfishException("Stockfish process terminated unexpectedly on init.")
|
@@ -180,7 +201,8 @@ def make_move():
|
|
180 |
stockfish_engine = get_stockfish_engine()
|
181 |
if stockfish_engine:
|
182 |
stockfish_engine.set_fen_position(board.fen())
|
183 |
-
|
|
|
184 |
if best_move_ai:
|
185 |
app.logger.info(f"Stockfish propose le coup: {best_move_ai}")
|
186 |
try:
|
|
|
24 |
# --- Configuration de la clé secrète ---
|
25 |
IS_DEBUG_MODE = True # Forcer le mode debug pour le développement local
|
26 |
# Pour la production, gérez FLASK_DEBUG et FLASK_SECRET_KEY via les variables d'environnement
|
27 |
+
default_depth_for_max_strength = 22
|
28 |
+
|
29 |
+
max_strength_params = {
|
30 |
+
"Debug Log File": "",
|
31 |
+
"Contempt": 0,
|
32 |
+
"Min Split Depth": 0,
|
33 |
+
"Threads": 4,
|
34 |
+
"Ponder": "false",
|
35 |
+
"Hash": 8192,
|
36 |
+
"MultiPV": 1,
|
37 |
+
"Skill Level": 20,
|
38 |
+
"Move Overhead": 30,
|
39 |
+
"Minimum Thinking Time": 20,
|
40 |
+
"Slow Mover": 100,
|
41 |
+
"UCI_Chess960": "false",
|
42 |
+
"UCI_LimitStrength": "false",
|
43 |
+
"UCI_Elo": 3500
|
44 |
+
}
|
45 |
|
46 |
if IS_DEBUG_MODE:
|
47 |
app.secret_key = 'dev_secret_key_pour_eviter_perte_session_rechargement_et_tests_v3' # Changez si besoin
|
|
|
101 |
app.logger.error("Exécutable Stockfish non disponible. L'IA ne peut pas démarrer.")
|
102 |
return None
|
103 |
try:
|
104 |
+
#engine = Stockfish(path=STOCKFISH_EXECUTABLE_PATH_GLOBAL, depth=15, parameters={"Threads": 1, "Hash": 64})
|
105 |
+
engine = Stockfish(path=STOCKFISH_EXECUTABLE_PATH_GLOBAL,
|
106 |
+
depth=default_depth_for_max_strength,
|
107 |
+
parameters=max_strength_params)
|
108 |
if engine._stockfish.poll() is not None:
|
109 |
app.logger.error("Le processus Stockfish s'est terminé de manière inattendue lors de l'initialisation.")
|
110 |
raise StockfishException("Stockfish process terminated unexpectedly on init.")
|
|
|
201 |
stockfish_engine = get_stockfish_engine()
|
202 |
if stockfish_engine:
|
203 |
stockfish_engine.set_fen_position(board.fen())
|
204 |
+
thinking_time_ms = 20000
|
205 |
+
best_move_ai = stockfish_engine.get_best_move(thinking_time_ms)
|
206 |
if best_move_ai:
|
207 |
app.logger.info(f"Stockfish propose le coup: {best_move_ai}")
|
208 |
try:
|