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)
There are three types of roles an agent can play in NetSecEnv:
- Attacker
- Defender
- Benign
Agents of each type are stored in the corresponding directory within this repository:
├── agents
├── attakcers
├── concepts_q_learning
├── double_q_learning
├── gnn_reinforce
├── interactive_tui
├── ...
├── defenders
├── random
├── probabilistic
├── benign
├── benign_random
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.
Additionally, there are several files with utils functions that can be used by any agents:
- `agent_utils.py Formatting GameState and generation of valid actions
- graph_agent_utils.py: GameState -> graph conversion
- llm_utils.py: utility functions for LLM-based agents
Agent | NetSecGame branch | Tag | Status |
---|---|---|---|
BaseAgent | main | HEAD |
✅ |
Random Attacker | 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 | ✅ |
Random Defender | main | 👷🏼♀️ | |
Probabilistic Defender | main | 👷🏼♀️ |
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 as part of the AIDojo Project.