@@ -2152,6 +2152,7 @@ def _variant(self, variant: Optional[str]) -> None:
21522152
21532153 def _new (self , board : chess .Board , game : object , options : ConfigMapping , opponent : Optional [Opponent ] = None ) -> None :
21542154 self ._configure (options )
2155+ self ._configure (self ._opponent_configuration (opponent = opponent ))
21552156
21562157 # Set up starting position.
21572158 root = board .root ()
@@ -2172,15 +2173,16 @@ def _new(self, board: chess.Board, game: object, options: ConfigMapping, opponen
21722173 if self .config .get ("random" ):
21732174 self .send_line ("random" )
21742175
2175- opponent_name = ( opponent . name if opponent else None ) or self .target_config .get ("name" )
2176+ opponent_name = self .config .get ("name" )
21762177 if opponent_name and self .features .get ("name" , True ):
21772178 self .send_line (f"name { opponent_name } " )
21782179
2179- opponent_rating = (opponent .rating if opponent else None ) or self .target_config .get ("opponent_rating" ) or 0
2180- if self .target_config .get ("engine_rating" ) or opponent_rating :
2181- self .send_line (f"rating { self .target_config .get ('engine_rating' ) or 0 } { opponent_rating } " )
2180+ opponent_rating = self .config .get ("opponent_rating" )
2181+ engine_rating = self .config .get ("engine_rating" )
2182+ if engine_rating or opponent_rating :
2183+ self .send_line (f"rating { engine_rating or 0 } { opponent_rating or 0 } " )
21822184
2183- if ( opponent and opponent . is_engine ) or ( self .target_config . get ( "computer" ) if self . config .get ("computer" ) is None else self . config . get ( "computer" ) ):
2185+ if self .config .get ("computer" ):
21842186 self .send_line ("computer" )
21852187
21862188 self .send_line ("force" )
@@ -2518,7 +2520,7 @@ def _opponent_configuration(self, *, opponent: Optional[Opponent] = None, engine
25182520 if opponent is None :
25192521 return {}
25202522
2521- opponent_info : Dict [str , Union [int , bool , str ]] = {"engine_rating" : engine_rating or 0 ,
2523+ opponent_info : Dict [str , Union [int , bool , str ]] = {"engine_rating" : engine_rating or self . target_config . get ( "engine_rating" ) or 0 ,
25222524 "opponent_rating" : opponent .rating or 0 ,
25232525 "computer" : opponent .is_engine or False }
25242526
0 commit comments