@@ -89,7 +89,8 @@ def __init__(
8989 player_initial_endowments : dict [str , dict [str , float ]],
9090 clock_now : Callable [[], datetime .datetime ],
9191 observations_component_name : str = (
92- observation_component .DEFAULT_OBSERVATION_COMPONENT_KEY ),
92+ observation_component .DEFAULT_OBSERVATION_COMPONENT_KEY
93+ ),
9394 memory_component_name : str = (
9495 memory_component .DEFAULT_MEMORY_COMPONENT_KEY
9596 ),
@@ -119,8 +120,8 @@ def __init__(
119120 amount of any item. Events where an item would have been gained lead to
120121 no change in the inventory and the game master instead invents a reason
121122 for why the item was not gained.
122- pre_act_label: Prefix to add to the output of the component when called
123- in `pre_act`.
123+ pre_act_label: Prefix to add to the output of the component when called in
124+ `pre_act`.
124125 verbose: whether to print the full update chain of thought or not
125126 """
126127 self ._pre_act_label = pre_act_label
@@ -181,13 +182,16 @@ def pre_act(
181182 if action_spec .output_type == entity_lib .OutputType .RESOLVE :
182183 with self ._lock :
183184 memory = self .get_entity ().get_component (
184- self ._memory_component_name , type_ = memory_component .Memory )
185+ self ._memory_component_name , type_ = memory_component .Memory
186+ )
185187
186188 observations = (
187- self .get_entity ().get_component (
189+ self .get_entity ()
190+ .get_component (
188191 self ._observations_component_name ,
189192 type_ = action_spec_ignored .ActionSpecIgnored ,
190- ).get_pre_act_value ()
193+ )
194+ .get_pre_act_value ()
191195 )
192196
193197 chain_of_thought = interactive_document .InteractiveDocument (self ._model )
@@ -311,9 +315,7 @@ def pre_act(
311315 # Add 's' to the end of the noun if it is a count noun.
312316 effect = effect + 's'
313317 inventory_effects .append (effect )
314- self ._add_to_game_master_memory (
315- message = effect
316- )
318+ self ._add_to_game_master_memory (message = effect )
317319 if self ._verbose :
318320 print (termcolor .colored (effect , 'yellow' ))
319321 else :
@@ -400,8 +402,6 @@ def get_state(self) -> entity_component.ComponentState:
400402 """Returns the state of the component."""
401403 return {'inventories' : self ._inventories }
402404
403- ############### NEW FUNCTIONS ################
404-
405405 def get_pre_act_label (self ) -> str :
406406 """Returns the pre act label of the component."""
407407 return self ._pre_act_label
@@ -412,11 +412,9 @@ def get_pre_act_value(self) -> str:
412412 return str (self ._inventories )
413413
414414
415- ################################################
416-
417-
418- class Score (entity_component .ContextComponent ,
419- entity_component .ComponentWithLogging ):
415+ class Score (
416+ entity_component .ContextComponent , entity_component .ComponentWithLogging
417+ ):
420418 """This component assigns score based on possession of items in inventory."""
421419
422420 def __init__ (
@@ -451,9 +449,12 @@ def get_scores(self) -> Mapping[str, float]:
451449 targets = self ._targets [name ]
452450 for target in targets :
453451 if self ._verbose :
454- print (termcolor .colored (
455- f'{ name } -- target = { target } , inventory = { inventory } ' ,
456- 'yellow' ))
452+ print (
453+ termcolor .colored (
454+ f'{ name } -- target = { target } , inventory = { inventory } ' ,
455+ 'yellow' ,
456+ )
457+ )
457458 if target in list (inventory .keys ()) and inventory [target ] > 0 :
458459 if self ._verbose :
459460 print (termcolor .colored (' target found in inventory.' , 'yellow' ))
@@ -468,8 +469,7 @@ def pre_act(
468469 ) -> str :
469470 del unused_action_spec
470471 self ._logging_channel (
471- {'Key' : 'score based on inventory' ,
472- 'Value' : self .get_scores ()}
472+ {'Key' : 'score based on inventory' , 'Value' : self .get_scores ()}
473473 )
474474 return ''
475475
0 commit comments