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.

Serpent Commands

setup

Perform first time setup for the framework. Creates configuration files, dataset directories and installs OS-specific dependencies.

Usage

Perform first time setup

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.

grab_frames

Start an instance of the Frame Grabber. Not meant for direct use

Usage

Start an instance of the Frame Grabber.

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

Activate a plugin. Makes it visible and accessible through Serpent.AI code.

Usage

Activate a plugin

serpent activate <plugin_name>

  • plugin_name: The name of a plugin in your plugins directory

deactivate

Deactivate a plugin. Makes it invisible and inaccessible through Serpent.AI code.

Usage

Deactivate a plugin

serpent deactivate <plugin_name>

  • plugin_name: The name of a plugin in your plugins directory

plugins

List active and inactive plugins.

Usage

List plugins

serpent plugins

launch

Launch a game through the appropriate active Serpent.AI plugin.

Usage

Launch a game

serpent launch <game_name>

  • game_name: The titleized name of the game (i.e. CoolGame).

play

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.

Usage

Play a game with the specified game agent

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

Generate code for Game and Game Agent Serpent.AI plugins.

Usage

Generate a Game plugin

serpent generate game

Generate a Game Agent plugin

serpent generate game_agent

train

Train machine learning models based on presets shipped with Serpent.AI.

Usage

Train a context classifier

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

Capture game frames and screen regions. The game needs to have already been launched through a serpent launch command.

Usage

Capture full game frames

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'

Capture full game frames with a context label

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>'

Capture a predefined region of game frames

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>'

visual_debugger

Launch the Visual Debugger.

Usage

Launch the Visual Debugger with the Default Buckets

serpent visual_debugger

Launch the Visual Debugger with Custom Buckets

serpent visual_debugger custom_1 custom_2

window_name

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.

Usage

Launch the utility

serpent window_name

⚠️ **GitHub.com Fallback** ⚠️