Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

yawning_titan.agents.nsa_red doesnt seem to be working (TypeError: 'NSARed' object is not callable) #47

Open
RiccardoGTolli opened this issue May 18, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@RiccardoGTolli
Copy link

When I try to create a NSARed agent it goes without errors but when I try to use it in yawning_titan.yawning_titan_run.YawningTitanRun it returns this error : TypeError: 'NSARed' object is not callable

Is there any other way to use NSARed?

# Provides the red agent behaviour within the `18-node-def` environment.
from yawning_titan.agents.nsa_red import NSARed

from stable_baselines3.common.env_checker import check_env
from stable_baselines3.common.evaluation import evaluate_policy


from yawning_titan.envs.generic.core.blue_interface import BlueInterface
from yawning_titan.envs.generic.core.red_interface import RedInterface
from yawning_titan.envs.generic.generic_env import GenericNetworkEnv
from yawning_titan.envs.generic.core.action_loops import ActionLoop
from yawning_titan.envs.generic.core.network_interface import NetworkInterface
from yawning_titan.networks.network_db import default_18_node_network
from yawning_titan.game_modes.game_mode_db import default_game_mode


# Build the Network
network = default_18_node_network()
# Build the GameModeConfig
game_mode = default_game_mode()
# Build the NetworkInterface
network_interface = NetworkInterface(game_mode=game_mode, network=network)

# Create the red and blue agents
red = RedInterface(network_interface)
blue = BlueInterface(network_interface)

# Set the red agent to the NSARed premade
red=NSARed(skill=0.5,
       action_set=red.action_set,
       action_probabilities=red.action_probabilities,
       node_set=red.node_set,
       zd_start_amount=0,
       zd_gain=0,
       zd_required=10)

# Create the environment
env = GenericNetworkEnv(red, blue, network_interface)
# check it s gym compliant;its not 
check_env(env, warn=True)
# reset any change during the check 
# _ = env.reset()

from yawning_titan.yawning_titan_run import YawningTitanRun
YawningTitanRun(network=default_18_node_network(),
                game_mode=default_game_mode(),
                red_agent_class=red,
                blue_agent_class=blue,
                print_metrics=False,
                show_metrics_every=1,
                collect_additional_per_ts_data=False,
                eval_freq=10000,
                total_timesteps=200000,
                training_runs=1,
                n_eval_episodes=1,
                deterministic=False,
                warn=True,
                render=False,
                verbose=1,
                logger=None,
                output_dir=None,
                auto=True)
@RiccardoGTolli RiccardoGTolli added the bug Something isn't working label May 18, 2023
@ChrisMcCarthyDev ChrisMcCarthyDev self-assigned this Jul 21, 2023
@ChrisMcCarthyDev
Copy link
Contributor

Thank you for raising this. This has been added to our internal backlog (reference 1645) and will be looked into by one of the dev team soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants