#2871 - Updated the show_history() function to receive a list of actions to ignore when printing the history. Defaults to ignoring DONOTHING actions
This commit is contained in:
@@ -139,22 +139,23 @@ class AbstractAgent(ABC):
|
|||||||
table.add_row([item.timestep, item.action, node, application, item.response.status])
|
table.add_row([item.timestep, item.action, node, application, item.response.status])
|
||||||
return table
|
return table
|
||||||
|
|
||||||
def show_history(self, include_nothing: bool = False):
|
def show_history(self, ignored_actions: Optional[list] = None):
|
||||||
"""
|
"""
|
||||||
Print an agent action provided it's not the DONOTHING action.
|
Print an agent action provided it's not the DONOTHING action.
|
||||||
|
|
||||||
:param include_nothing: boolean for including DONOTHING actions. Default False.
|
:param ignored_actions: OPTIONAL: List of actions to be ignored when displaying the history.
|
||||||
|
If not provided, defaults to ignore DONOTHING actions.
|
||||||
"""
|
"""
|
||||||
|
if not ignored_actions:
|
||||||
|
ignored_actions = ["DONOTHING"]
|
||||||
table = PrettyTable()
|
table = PrettyTable()
|
||||||
table.field_names = ["Step", "Action", "Node", "Application", "Response"]
|
table.field_names = ["Step", "Action", "Node", "Application", "Response"]
|
||||||
print(f"Actions for '{self.agent_name}':")
|
print(f"Actions for '{self.agent_name}':")
|
||||||
for item in self.history:
|
for item in self.history:
|
||||||
if item.action == "DONOTHING":
|
if item.action in ignored_actions:
|
||||||
if include_nothing:
|
|
||||||
table = self.add_agent_action(item=item, table=table)
|
|
||||||
else:
|
|
||||||
pass
|
pass
|
||||||
self.add_agent_action(item=item, table=table)
|
else:
|
||||||
|
table = self.add_agent_action(item=item, table=table)
|
||||||
print(table)
|
print(table)
|
||||||
|
|
||||||
def update_observation(self, state: Dict) -> ObsType:
|
def update_observation(self, state: Dict) -> ObsType:
|
||||||
|
|||||||
Reference in New Issue
Block a user