The serpent Executable - nanpuhaha/SerpentAI GitHub Wiki
One very important tool to learn and understand in order to master the framework is the serpent executable. A lot of major features can be accessed by invoking the right serpent command.
Try it out right now. Run serpent
.
You should see something similar to what's in the image above. Let's proceed to cover these commands one-by-one.
Perform first time setup for the framework. Creates configuration files, dataset directories and installs OS-specific dependencies.
serpent setup
Note: It will remain possible to invoke this command again later on. Be aware that it WILL deactivate all plugins, override configuration files and delete all datasets. You will be asked for confirmation before proceeding.
Start an instance of the Frame Grabber. Not meant for direct use
serpent grab_frames <width> <height> <x_offset> <y_offset>
- width: Width in pixels of the game frames to capture
- height: Height in pixels of the game frames to capture
- x_offset: X offset in pixels of the game frames to capture
- y_offset: Y offset in pixels of the game frames to capture
Note: This is executed in the background by Game objects when starting up a Game Agent.
Activate a plugin. Makes it visible and accessible through Serpent.AI code.
serpent activate <plugin_name>
- plugin_name: The name of a plugin in your plugins directory
Deactivate a plugin. Makes it invisible and inaccessible through Serpent.AI code.
serpent deactivate <plugin_name>
- plugin_name: The name of a plugin in your plugins directory
List active and inactive plugins.
serpent plugins
Launch a game through the appropriate active Serpent.AI plugin.
serpent launch <game_name>
- game_name: The titleized name of the game (i.e. CoolGame).
Play a game with the specified game agent through the appropriate Serpent.AI plugin. The game needs to have already been launched through a serpent launch
command.
serpent play <game_name> <game_agent_plugin_name> <frame_handler>
- game_name: The titleized name of the game (i.e. CoolGame).
- game_agent_plugin_name: The full name of the game agent (i.e. SerpentCoolGameGameAgent)
- frame_handler: A frame handler label. Optional. Default will rely on plugin config.
Generate code for Game and Game Agent Serpent.AI plugins.
serpent generate game
serpent generate game_agent
Train machine learning models based on presets shipped with Serpent.AI.
serpent train context <epochs>
- epochs: Number of epochs to train over. Optional. Defaults to 3
Requires prior capture of context frames using serpent capture
Capture game frames and screen regions. The game needs to have already been launched through a serpent launch
command.
serpent capture frame <game_name> <interval>
- game_name: The titleized name of the game (i.e. CoolGame).
- interval: The time to wait in seconds between captures. Defaults to 1 second.
Captured game frames will be stored in 'datasets/collect_frames'
serpent capture context <game_name> <interval> <context_label>
- game_name: The titleized name of the game (i.e. CoolGame).
- interval: The time to wait in seconds between captures. Defaults to 1 second.
- context_label*: The label to apply to the captured
Captured game frames will be stored in 'datasets/collect_frames_for_context/<context_label>'
serpent capture region <game_name> <interval> <screen_region>
- game_name: The titleized name of the game (i.e. CoolGame).
- interval: The time to wait in seconds between captures. Defaults to 1 second.
- screen_region*: A valid screen region name defined in the Game plugin.
Captured game frames will be stored in 'datasets/collect_frames/<screen_region>'
Launch the Visual Debugger.
serpent visual_debugger
serpent visual_debugger custom_1 custom_2
Launch a CLI utility to assist in determining the correct value for the window name variable in your Game plugin. Mostly meant for macOS since window titles can be used directly on Linux and Windows.
serpent window_name