Agents located in this repository should be use in the Network Security Game environment. They are intented for a navigation and problem solving in the adversarial network-security based environment where they play role of attackers or defenders.
All future agents should extend BaseAgent - a minimal implementation of agent capable of interaction with he environment. The base agent also implement logging capabilities for the agent via the logging
module of python. The logger can be accessed by property logger
.
For creating an instance of a BaseAgent
, three parameters have to be used:
host:str
- URL where the game server runsport: int
- port number where game server runsrole: str
- Intended role of the agent. Options areAttacker
,Defender
,Human
When extending the BaseAgent
, these args should be passed to in the constructor by calling:
super().__init__(host, port, role)
There are 4 important methods to be used for interaction with the environment:
register()
: Should be used ONCE in the beginning of the interaction to register the agent in the game.- Uses the class name and
role
specified in the initialization for the registration in the game - returns
Observation
which contains the status of the registration and the initialGameState
if the registration was successful
- Uses the class name and
make_step(Action: action)
: Used for sending aAction
object to be used as a next step of the agent. ReturnsObservation
with new state fo the environment after the action was applied.request_game_reset()
: Used to RESET the state of the environment to its initial position (e.g. at the end of an episode). ReturnsObservation
with state of the environment.terminate_connection()
: Should be used ONCE at the end of the interaction to properly disconnect the agent from the game server.
Examples of agents extending the BaseAgent can be found in:
- RandomAgent
- InteractiveAgent
- Q-learningAgent (Documentation here)
Agent | NetSecGame branch | Tag |
---|---|---|
BaseAgent | main | HEAD |
RandomAgent | main | HEAD |
InteractiveAgent | main | HEAD |
Q-learning | main | HEAD |
LLM | main | realease_out_of_the_cage |
LLM_QA | main | realease_out_of_the_cage |
GNN_REINFORCE | main | realease_out_of_the_cage |
Utility functions in agent_utils.py can be used by any agent to evaluate a GameState
, generate set of valid Actions
in a GameState
etc.
This code was developed at the Stratosphere Laboratory at the Czech Technical University in Prague.
- export MLFLOW_TRACKING_URI=sqlite:///mlruns.db
- Then run the agent code
From the folder that you run the python
mlflow ui --port 8080 --backend-store-uri sqlite:///mlruns.db