6060
6161
6262APP_NAME = 'Python Easy Chess GUI'
63- APP_VERSION = 'v1.7 '
63+ APP_VERSION = 'v1.8 '
6464BOX_TITLE = '{} {}' .format (APP_NAME , APP_VERSION )
6565
6666
@@ -2505,6 +2505,31 @@ def build_main_layout(self, is_user_white=True):
25052505 ]
25062506
25072507 return layout
2508+
2509+ def set_default_adviser_engine (self ):
2510+ try :
2511+ self .adviser_id_name = self .engine_id_name_list [1 ] \
2512+ if len (self .engine_id_name_list ) >= 2 \
2513+ else self .engine_id_name_list [0 ]
2514+ self .adviser_file , self .adviser_path_and_file = \
2515+ self .get_engine_file (self .adviser_id_name )
2516+ except IndexError as e :
2517+ logging .warning (e )
2518+ except Exception :
2519+ logging .exception ('Error in getting adviser engine!' )
2520+
2521+ def get_default_engine_opponent (self ):
2522+ engine_id_name = None
2523+ try :
2524+ engine_id_name = self .opp_id_name = self .engine_id_name_list [0 ]
2525+ self .opp_file , self .opp_path_and_file = self .get_engine_file (
2526+ engine_id_name )
2527+ except IndexError as e :
2528+ logging .warning (e )
2529+ except Exception :
2530+ logging .exception ('Error in getting opponent engine!' )
2531+
2532+ return engine_id_name
25082533
25092534 def main_loop (self ):
25102535 """
@@ -2529,26 +2554,10 @@ def main_loop(self):
25292554 self .engine_id_name_list = self .get_engine_id_name_list ()
25302555
25312556 # Define default opponent engine, user can change this later.
2532- try :
2533- engine_id_name = self .opp_id_name = self .engine_id_name_list [0 ]
2534- self .opp_file , self .opp_path_and_file = self .get_engine_file (
2535- engine_id_name )
2536- except IndexError as e :
2537- logging .warning (e )
2538- except Exception :
2539- logging .exception ('Error in getting opponent engine!' )
2557+ engine_id_name = self .get_default_engine_opponent ()
25402558
25412559 # Define default adviser engine, user can change this later.
2542- try :
2543- self .adviser_id_name = self .engine_id_name_list [1 ] \
2544- if len (self .engine_id_name_list ) >= 2 \
2545- else self .engine_id_name_list [0 ]
2546- self .adviser_file , self .adviser_path_and_file = self .get_engine_file (
2547- self .adviser_id_name )
2548- except IndexError as e :
2549- logging .warning (e )
2550- except Exception :
2551- logging .exception ('Error in getting adviser engine!' )
2560+ self .set_default_adviser_engine ()
25522561
25532562 self .init_game ()
25542563
@@ -2955,6 +2964,15 @@ def main_loop(self):
29552964
29562965 install_win .Close ()
29572966 window .Enable ()
2967+
2968+ # Define default engine opponent and adviser
2969+ if engine_id_name is None :
2970+ engine_id_name = self .get_default_engine_opponent ()
2971+ if self .adviser_id_name is None :
2972+ self .set_default_adviser_engine ()
2973+
2974+ self .update_labels_and_game_tags (window , human = self .username )
2975+
29582976 continue
29592977
29602978 # Mode: Neutral
0 commit comments