Game Components
AIDojoCoordinator.game_components
Action(action_type, parameters=dict())
dataclass
Immutable dataclass representing an Action.
Attributes:
Name | Type | Description |
---|---|---|
action_type |
ActionType
|
The type of action. |
parameters |
Dict[str, Any]
|
Parameters for the action. |
as_dict
property
Return a dictionary representation of the Action.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The action as a dictionary. |
type
property
__eq__(other)
Check equality with another Action object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
Another Action object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if equal, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
|
__hash__()
Compute the hash of the Action.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash value. |
Source code in AIDojoCoordinator/game_components.py
506 507 508 509 510 511 512 513 514 515 |
|
__repr__()
Return the string representation of the Action.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The action as a string. |
Source code in AIDojoCoordinator/game_components.py
471 472 473 474 475 476 477 478 |
|
__str__()
Return the string representation of the Action.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The action as a string. |
Source code in AIDojoCoordinator/game_components.py
480 481 482 483 484 485 486 487 |
|
from_dict(data_dict)
classmethod
Create an Action from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict
|
Dict[str, Any]
|
The action as a dictionary. |
required |
Returns:
Name | Type | Description |
---|---|---|
Action |
Action
|
The created Action object. |
Raises:
Type | Description |
---|---|
ValueError
|
If an unsupported parameter is encountered. |
Source code in AIDojoCoordinator/game_components.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
from_json(json_string)
classmethod
Create an Action from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The JSON string representation. |
required |
Returns:
Name | Type | Description |
---|---|---|
Action |
Action
|
The created Action object. |
Source code in AIDojoCoordinator/game_components.py
457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
to_json()
Serialize the Action to a JSON string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The JSON string representation. |
Source code in AIDojoCoordinator/game_components.py
414 415 416 417 418 419 420 421 |
|
ActionType
Bases: Enum
Enum representing possible action types in the NetSecGame.
__eq__(other)
Compare ActionType with another ActionType or string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
ActionType or str
|
The object to compare. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if equal, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
__hash__()
Compute the hash of the ActionType.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash value. |
Source code in AIDojoCoordinator/game_components.py
310 311 312 313 314 315 316 317 318 |
|
from_string(name)
classmethod
Convert a string to an ActionType enum. Strips 'ActionType.' if present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The string representation. |
required |
Returns:
Name | Type | Description |
---|---|---|
ActionType |
ActionType
|
The corresponding ActionType. |
Raises:
Type | Description |
---|---|
ValueError
|
If the string does not match any ActionType. |
Source code in AIDojoCoordinator/game_components.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
to_string()
Convert the ActionType enum to string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The string representation. |
Source code in AIDojoCoordinator/game_components.py
283 284 285 286 287 288 289 290 |
|
AgentInfo(name, role)
dataclass
Represents agent information.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the agent. |
role |
str
|
Role of the agent. |
__repr__()
Return the string representation of the AgentInfo.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The agent info as a string. |
Source code in AIDojoCoordinator/game_components.py
353 354 355 356 357 358 359 360 |
|
from_dict(data)
classmethod
Build the AgentInfo object from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary with agent info attributes. |
required |
Returns:
Name | Type | Description |
---|---|---|
AgentInfo |
AgentInfo
|
The created AgentInfo object. |
Source code in AIDojoCoordinator/game_components.py
363 364 365 366 367 368 369 370 371 372 373 374 |
|
AgentStatus
Bases: Enum
Enum representing possible agent statuses.
__eq__(other)
Compare AgentStatus with another AgentStatus or string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
AgentStatus or str
|
The object to compare. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if equal, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 |
|
__hash__()
Compute the hash of the AgentStatus.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash value. |
Source code in AIDojoCoordinator/game_components.py
785 786 787 788 789 790 791 792 793 |
|
from_string(name)
classmethod
Convert a string to an AgentStatus enum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The string representation. |
required |
Returns:
Name | Type | Description |
---|---|---|
AgentStatus |
AgentStatus
|
The corresponding AgentStatus. |
Raises:
Type | Description |
---|---|
ValueError
|
If the string does not match any AgentStatus. |
Source code in AIDojoCoordinator/game_components.py
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
|
to_string()
Convert the AgentStatus enum to string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The string representation. |
Source code in AIDojoCoordinator/game_components.py
758 759 760 761 762 763 764 765 |
|
Data(owner, id, size=0, type='', content=str())
dataclass
Represents a data object in the NetSecGame.
Attributes:
Name | Type | Description |
---|---|---|
owner |
str
|
Owner of the data. |
id |
str
|
Identifier of the data. |
size |
int
|
Size of the data. Default = 0 |
type |
str
|
Type of the data. Default = "" |
content |
str
|
Content of the data. Default = "" |
__hash__()
Compute the hash of the Data object.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The hash value. |
Source code in AIDojoCoordinator/game_components.py
247 248 249 250 251 252 253 254 |
|
from_dict(data)
classmethod
Build the Data object from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary with data attributes. |
required |
Returns:
Name | Type | Description |
---|---|---|
Data |
Data
|
The created Data object. |
Source code in AIDojoCoordinator/game_components.py
255 256 257 258 259 260 261 262 263 264 265 266 |
|
GameState(controlled_hosts=set(), known_hosts=set(), known_services=dict(), known_data=dict(), known_networks=set(), known_blocks=dict())
dataclass
Represents the state of the game.
Attributes:
Name | Type | Description |
---|---|---|
controlled_hosts |
set
|
Controlled hosts. |
known_hosts |
set
|
Known hosts. |
known_services |
dict
|
Known services. |
known_data |
dict
|
Known data. |
known_networks |
set
|
Known networks. |
known_blocks |
dict
|
Known blocks. |
as_dict
property
Return the dictionary representation of the GameState.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The game state as a dictionary. |
as_graph
property
Build a graph representation of the game state.
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple
|
(node_features, controlled, edges, node_index_map) |
__str__()
Return the string representation of the GameState.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The game state as a string. |
Source code in AIDojoCoordinator/game_components.py
605 606 607 608 609 610 611 612 |
|
as_json()
Return the JSON representation of the GameState.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The JSON string. |
Source code in AIDojoCoordinator/game_components.py
614 615 616 617 618 619 620 621 622 |
|
from_dict(data_dict)
classmethod
Create a GameState from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict
|
dict
|
The game state as a dictionary. |
required |
Returns:
Name | Type | Description |
---|---|---|
GameState |
GameState
|
The created GameState object. |
Source code in AIDojoCoordinator/game_components.py
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
from_json(json_string)
classmethod
Create a GameState from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The JSON string. |
required |
Returns:
Name | Type | Description |
---|---|---|
GameState |
GameState
|
The created GameState object. |
Source code in AIDojoCoordinator/game_components.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
|
GameStatus
Bases: Enum
Enum representing possible game statuses.
__repr__()
Return the string representation of the GameStatus.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The game status as a string. |
Source code in AIDojoCoordinator/game_components.py
736 737 738 739 740 741 742 743 |
|
from_string(string)
classmethod
Convert a string to a GameStatus enum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string
|
str
|
The string representation. |
required |
Returns:
Name | Type | Description |
---|---|---|
GameStatus |
GameStatus
|
The corresponding GameStatus. |
Source code in AIDojoCoordinator/game_components.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
|
IP(ip)
dataclass
Immutable object representing an IPv4 address in the NetSecGame.
Attributes:
Name | Type | Description |
---|---|---|
ip |
str
|
The IP address in dot-decimal notation. |
__eq__(other)
Check equality with another IP object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
IP
|
Another IP object. |
required |
Returns:
Name | Type | Description |
---|---|---|
is_equal |
bool
|
True if equal, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
__hash__()
Compute the hash of the IP.
Returns:
Name | Type | Description |
---|---|---|
hash |
int
|
The hash value. |
Source code in AIDojoCoordinator/game_components.py
119 120 121 122 123 124 125 126 |
|
__post_init__()
Verify if the provided IP is valid.
Raises:
Type | Description |
---|---|
ValueError
|
If the IP address is invalid. |
Source code in AIDojoCoordinator/game_components.py
55 56 57 58 59 60 61 62 63 64 65 |
|
__repr__()
Return the string representation of the IP.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The IP address. |
Source code in AIDojoCoordinator/game_components.py
67 68 69 70 71 72 73 74 |
|
from_dict(data)
classmethod
Build the IP object from a dictionary representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary with IP attributes. |
required |
Returns:
Name | Type | Description |
---|---|---|
IP |
IP
|
The created IP object. |
Source code in AIDojoCoordinator/game_components.py
106 107 108 109 110 111 112 113 114 115 116 117 |
|
is_private()
Check if the IP address is private. Uses ipaddress module.
Returns:
Name | Type | Description |
---|---|---|
is_private |
bool
|
True if the IP is private, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
Network(ip, mask)
dataclass
Immutable object representing an IPv4 network in the NetSecGame.
Attributes:
Name | Type | Description |
---|---|---|
ip |
str
|
IP address of the network. |
mask |
int
|
CIDR mask of the network. |
__gt__(other)
Greater-than comparison for networks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Network
|
Another network. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if self > other, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
__le__(other)
Less-than-or-equal comparison for networks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Network
|
Another network. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if self <= other, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
__lt__(other)
Less-than comparison for networks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Network
|
Another network. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if self < other, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
__repr__()
Return the string representation of the network.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The network in CIDR notation. |
Source code in AIDojoCoordinator/game_components.py
140 141 142 143 144 145 146 147 |
|
__str__()
Return the string representation of the network.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The network in CIDR notation. |
Source code in AIDojoCoordinator/game_components.py
149 150 151 152 153 154 155 156 |
|
from_dict(data)
classmethod
Build the Network object from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary with network attributes. |
required |
Returns:
Name | Type | Description |
---|---|---|
Network |
Network
|
The created Network object. |
Source code in AIDojoCoordinator/game_components.py
216 217 218 219 220 221 222 223 224 225 226 227 |
|
is_private()
Check if the network is private. Uses ipaddress module.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the network is private, False otherwise. |
Source code in AIDojoCoordinator/game_components.py
203 204 205 206 207 208 209 210 211 212 213 214 |
|
ProtocolConfig()
dataclass
Configuration for protocol constants.
Attributes:
Name | Type | Description |
---|---|---|
END_OF_MESSAGE |
bytes
|
End-of-message marker. |
BUFFER_SIZE |
int
|
Buffer size for messages. |
Service(name, type='unknown', version='unknown', is_local=True)
dataclass
Represents a service in the NetSecGame.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the service. |
type |
str
|
Type of the service. Default |
version |
str
|
Version of the service. Default |
is_local |
bool
|
Whether the service is local. Default True |
from_dict(data)
classmethod
Create a Service object from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
Dictionary with service attributes. |
required |
Returns:
Name | Type | Description |
---|---|---|
Service |
Service
|
The created Service object. |
Source code in AIDojoCoordinator/game_components.py
31 32 33 34 35 36 37 38 39 40 41 42 |
|