melee package

Submodules

melee.console module

The Console represents the engine running the game.

This can be Dolphin (Ishiiruka), A Nintendont Wii, or an SLP file (TODO)

class melee.console.Console(is_dolphin, ai_port, opponent_port, opponent_type, dolphin_executable_path=None, slippi_address='', logger=None)

Bases: object

The console object that represents your Dolphin / Wii / SLP file

slippi_address

IP address of the Dolphin / Wii to connect to. Empty string will try to autodiscover a nearby SlippiComm server

Type:str
slippi_port

TCP port of slippi server. Default 51441

Type:int
connect()

Connects to the Slippi server (dolphin or wii).

Returns:True is successful, False otherwise
get_dolphin_pipes_path(port)

Get the path of the named pipe input file for the given controller port

run(iso_path=None, movie_path=None, dolphin_config_path=None)

Run dolphin-emu

Parameters:
  • iso_path (str, optional) – Path to Melee ISO for dolphin to read
  • dolphin_config_path (str, optional) – Alternative config path for dolphin if not using the default
setup_dolphin_controller(port, controllertype=<ControllerType.STANDARD: '6'>)

Setup the necessary files for dolphin to recognize the player at the given controller port and type

step()

‘step’ to the next state of the game Returns a new gamestate object that represents current state of the game

stop()

Stop the console.

For Dolphin instances, this will kill the dolphin process. For Wiis and SLP files, it just shuts down our connection

melee.controller module

Defines a Clontroller class that manages pressing buttons for your console

class melee.controller.Controller(console, port, serial_device='/dev/ttyACM0')

Bases: object

Utility class that manages virtual controller state and button presses

connect()

Connect the controller to the console NOTE: Blocks until the other side is ready

disconnect()

Disconnects the controller from the console

empty_input()

Helper function to reset the controller to a resting state

All buttons are released, all sticks set to 0.5

flush()

Actually send the button presses to the console

Up until this point, any buttons you ‘press’ are just queued in a pipe. It doesn’t get sent to the console until you flush

press_button(button)

Press a single button

If already pressed, this has no effect

press_shoulder(button, amount)

Press the analog shoulder buttons to a given amount

button - Button enum. Has to be L or R amount - Float between 0 (not pressed at all) and 1 (Fully pressed in)

Note that the ‘digital’ button press of L or R are handled separately
as normal button presses. Pressing the shoulder all the way in will not cause the digital button to press
release_button(button)

Unpress a single button

If already released, this has no effect

simple_press(x, y, button)

Here is a simpler representation of a button press, in case you don’t want to bother with the tedium of manually doing everything. It isn’t capable of doing everything the normal controller press functions can, but probably covers most scenarios. Notably, a difference here is that doing a button press releases all other buttons pressed previously.

Note

Don’t call this function twice in the same frame
x = 0 (left) to 1 (right) on the main stick y = 0 (down) to 1 (up) on the main stick button = the button to press. Enter None for no button
tilt_analog(button, x, y)

Tilt one of the analog sticks to a given (x,y) value

button - Button enum. Must be main stick or C stick x - Float between 0 (left) and 1 (right) y - Float between 0 (down) and 1 (up)

class melee.controller.ControllerState

Bases: object

A snapshot of the state of a virtual controller

to_bytes()

Serialize the controller state into an 8 byte sequence that the Gamecube uses

melee.enums module

Enum values for various Melee objects

class melee.enums.Action

Bases: enum.Enum

The in-game action (or animation) a character can be in NOTE: Numeric values represent their Slippi-defined in-game values

AIRDODGE = 236
BACKWARD_TECH = 201
BAIR = 67
BAIR_LANDING = 72
BARREL_CANNON_WAIT = 340
BARREL_WAIT = 293
BAT_SWING_1 = 124
BAT_SWING_2 = 125
BAT_SWING_3 = 126
BAT_SWING_4 = 127
BEAM_SWORD_SWING_1 = 120
BEAM_SWORD_SWING_2 = 121
BEAM_SWORD_SWING_3 = 122
BEAM_SWORD_SWING_4 = 123
BOUNCE_CEILING = 248
BOUNCE_WALL = 247
BUMP_CIELING = 250
BUMP_WALL = 249
BURY = 294
BURY_JUMP = 296
BURY_WAIT = 295
CAPTURE_CAPTAIN = 275
CAPTURE_CRAZYHAND = 336
CAPTURE_DAMAGE_CRAZYHAND = 337
CAPTURE_DAMAGE_KOOPA = 279
CAPTURE_DAMAGE_KOOPA_AIR = 284
CAPTURE_DAMAGE_MASTERHAND = 328
CAPTURE_KIRBY = 288
CAPTURE_KIRBY_YOSHI = 331
CAPTURE_KOOPA = 278
CAPTURE_KOOPA_AIR = 283
CAPTURE_KOOPA_AIR_HIT = 378
CAPTURE_LEA_DEAD = 333
CAPTURE_LIKE_LIKE = 334
CAPTURE_MASTERHAND = 327
CAPTURE_MEWTWO = 301
CAPTURE_MEWTWO_AIR = 302
CAPTURE_WAIT_CRAZYHAND = 338
CAPTURE_WAIT_KIRBY = 289
CAPTURE_WAIT_KOOPA = 280
CAPTURE_WAIT_KOOPA_AIR = 285
CAPTURE_WAIT_MASTERHAND = 329
CAPTURE_YOSHI = 276
CEILING_TECH = 204
CROUCHING = 40
CROUCH_END = 41
CROUCH_START = 39
DAIR = 69
DAIR_LANDING = 74
DAMAGE_AIR_1 = 84
DAMAGE_AIR_2 = 85
DAMAGE_AIR_3 = 86
DAMAGE_BIND = 300
DAMAGE_FLY_HIGH = 87
DAMAGE_FLY_LOW = 89
DAMAGE_FLY_NEUTRAL = 88
DAMAGE_FLY_ROLL = 91
DAMAGE_FLY_TOP = 90
DAMAGE_GROUND = 193
DAMAGE_HIGH_1 = 75
DAMAGE_HIGH_2 = 76
DAMAGE_HIGH_3 = 77
DAMAGE_ICE = 325
DAMAGE_ICE_JUMP = 326
DAMAGE_LOW_1 = 81
DAMAGE_LOW_2 = 82
DAMAGE_LOW_3 = 83
DAMAGE_NEUTRAL_1 = 78
DAMAGE_NEUTRAL_2 = 79
DAMAGE_NEUTRAL_3 = 80
DAMAGE_SCREW = 156
DAMAGE_SCREW_AIR = 157
DAMAGE_SONG = 297
DAMAGE_SONG_RV = 299
DAMAGE_SONG_WAIT = 298
DASHING = 20
DASH_ATTACK = 50
DEAD_DOWN = 0
DEAD_FALL = 35
DEAD_FLY = 6
DEAD_FLY_SPLATTER = 7
DEAD_FLY_SPLATTER_FLAT = 8
DEAD_FLY_SPLATTER_FLAT_ICE = 10
DEAD_FLY_SPLATTER_ICE = 9
DEAD_FLY_STAR = 4
DEAD_FLY_STAR_ICE = 5
DEAD_LEFT = 1
DEAD_RIGHT = 2
DEAD_UP = 3
DOWNSMASH = 64
DOWNTILT = 57
DOWN_B_AIR = 366
DOWN_B_GROUND = 361
DOWN_B_GROUND_START = 360
DOWN_B_STUN = 365
DOWN_REFLECT = 335
EDGE_ATTACK_QUICK = 257
EDGE_ATTACK_SLOW = 256
EDGE_CATCHING = 252
EDGE_GETUP_QUICK = 255
EDGE_GETUP_SLOW = 254
EDGE_HANGING = 253
EDGE_JUMP_1_QUICK = 262
EDGE_JUMP_1_SLOW = 260
EDGE_JUMP_2_QUICK = 263
EDGE_JUMP_2_SLOW = 261
EDGE_ROLL_QUICK = 259
EDGE_ROLL_SLOW = 258
EDGE_TEETERING = 246
EDGE_TEETERING_START = 245
ENTRY = 322
ENTRY_END = 324
ENTRY_START = 323
FAIR = 66
FAIR_LANDING = 71
FALLING = 29
FALLING_AERIAL = 32
FALLING_AERIAL_BACKWARD = 34
FALLING_AERIAL_FORWARD = 33
FALLING_BACKWARD = 31
FALLING_FORWARD = 30
FAN_SWING_1 = 132
FAN_SWING_2 = 133
FAN_SWING_3 = 134
FAN_SWING_4 = 135
FIREFOX_AIR = 356
FIREFOX_GROUND = 355
FIREFOX_WAIT_AIR = 354
FIREFOX_WAIT_GROUND = 353
FIRE_FLOWER_SHOOT = 152
FIRE_FLOWER_SHOOT_AIR = 153
FORWARD_TECH = 200
FOX_ILLUSION = 351
FOX_ILLUSION_SHORTENED = 352
FOX_ILLUSION_START = 350
FSMASH_HIGH = 58
FSMASH_LOW = 62
FSMASH_MID = 60
FSMASH_MID_HIGH = 59
FSMASH_MID_LOW = 61
FTILT_HIGH = 51
FTILT_HIGH_MID = 52
FTILT_LOW = 55
FTILT_LOW_MID = 54
FTILT_MID = 53
GETUP_ATTACK = 195
GRAB = 212
GRABBED = 227
GRABBED_WAIT_HIGH = 224
GRAB_BREAK = 218
GRAB_ESCAPE = 229
GRAB_FOOT = 232
GRAB_JUMP = 230
GRAB_NECK = 231
GRAB_PULL = 226
GRAB_PULLING = 213
GRAB_PULLING_HIGH = 223
GRAB_PUMMEL = 217
GRAB_PUMMELED = 228
GRAB_RUNNING = 214
GRAB_RUNNING_PULLING = 215
GRAB_WAIT = 216
GROUND_ATTACK_UP = 187
GROUND_GETUP = 186
GROUND_ROLL_BACKWARD_DOWN = 197
GROUND_ROLL_BACKWARD_UP = 189
GROUND_ROLL_FORWARD_DOWN = 196
GROUND_ROLL_FORWARD_UP = 188
GROUND_ROLL_SPOT_DOWN = 198
GROUND_SPOT_UP = 190
GUN_SHOOT = 148
GUN_SHOOT_AIR = 149
GUN_SHOOT_AIR_EMPTY = 151
GUN_SHOOT_EMPTY = 150
HAMMER_FALL = 311
HAMMER_JUMP = 312
HAMMER_KNEE_BEND = 310
HAMMER_LANDING = 313
HAMMER_TURN = 309
HAMMER_WAIT = 307
HAMMER_WALK = 308
ITEM_PARASOL_DAMAGE_FALL = 147
ITEM_PARASOL_FALL = 145
ITEM_PARASOL_FALL_SPECIAL = 146
ITEM_PARASOL_OPEN = 144
ITEM_PICKUP_HEAVY = 93
ITEM_PICKUP_LIGHT = 92
ITEM_SCOPE_AIR_END = 165
ITEM_SCOPE_AIR_END_EMPTY = 173
ITEM_SCOPE_AIR_FIRE = 164
ITEM_SCOPE_AIR_FIRE_EMPTY = 172
ITEM_SCOPE_AIR_RAPID = 163
ITEM_SCOPE_AIR_RAPID_EMPTY = 171
ITEM_SCOPE_AIR_START = 162
ITEM_SCOPE_AIR_START_EMPTY = 170
ITEM_SCOPE_END = 161
ITEM_SCOPE_END_EMPTY = 169
ITEM_SCOPE_FIRE = 160
ITEM_SCOPE_FIRE_EMPTY = 168
ITEM_SCOPE_RAPID = 159
ITEM_SCOPE_RAPID_EMPTY = 167
ITEM_SCOPE_START = 158
ITEM_SCOPE_START_EMPTY = 166
ITEM_SCREW = 154
ITEM_SCREW_AIR = 155
ITEM_THROW_HEAVY_AIR_SMASH_BACK = 117
ITEM_THROW_HEAVY_AIR_SMASH_FORWARD = 116
ITEM_THROW_HEAVY_AIR_SMASH_HIGH = 118
ITEM_THROW_HEAVY_AIR_SMASH_LOW = 119
ITEM_THROW_HEAVY_BACK = 105
ITEM_THROW_HEAVY_FORWARD = 104
ITEM_THROW_HEAVY_HIGH = 106
ITEM_THROW_HEAVY_LOW = 107
ITEM_THROW_LIGHT_AIR_BACK = 101
ITEM_THROW_LIGHT_AIR_FORWARD = 100
ITEM_THROW_LIGHT_AIR_HIGH = 102
ITEM_THROW_LIGHT_AIR_LOW = 103
ITEM_THROW_LIGHT_AIR_SMASH_BACK = 113
ITEM_THROW_LIGHT_AIR_SMASH_FORWARD = 112
ITEM_THROW_LIGHT_AIR_SMASH_HIGH = 114
ITEM_THROW_LIGHT_AIR_SMASH_LOW = 115
ITEM_THROW_LIGHT_BACK = 95
ITEM_THROW_LIGHT_DASH = 98
ITEM_THROW_LIGHT_DROP = 99
ITEM_THROW_LIGHT_FORWARD = 94
ITEM_THROW_LIGHT_HIGH = 96
ITEM_THROW_LIGHT_LOW = 97
ITEM_THROW_LIGHT_SMASH_BACK = 109
ITEM_THROW_LIGHT_SMASH_DOWN = 111
ITEM_THROW_LIGHT_SMASH_FORWARD = 108
ITEM_THROW_LIGHT_SMASH_UP = 110
JUMPING_ARIAL_BACKWARD = 28
JUMPING_ARIAL_FORWARD = 27
JUMPING_BACKWARD = 26
JUMPING_FORWARD = 25
KINOKO_GIANT_END = 316
KINOKO_GIANT_END_AIR = 317
KINOKO_GIANT_START = 314
KINOKO_GIANT_START_AIR = 315
KINOKO_SMALL_END = 320
KINOKO_SMALL_END_AIR = 321
KINOKO_SMALL_START = 318
KINOKO_SMALL_START_AIR = 319
KIRBY_YOSHI_EGG = 332
KNEE_BEND = 24
LANDING = 42
LANDING_SPECIAL = 43
LASER_GUN_PULL = 341
LIFT_TURN = 177
LIFT_WAIT = 174
LIFT_WALK_1 = 175
LIFT_WALK_2 = 176
LIP_STICK_SWING_1 = 140
LIP_STICK_SWING_2 = 141
LIP_STICK_SWING_3 = 142
LIP_STICK_SWING_4 = 143
LOOPING_ATTACK_END = 49
LOOPING_ATTACK_MIDDLE = 48
LOOPING_ATTACK_START = 47
LYING_GROUND_DOWN = 192
LYING_GROUND_UP = 184
LYING_GROUND_UP_HIT = 185
MARTH_COUNTER = 369
MARTH_COUNTER_FALLING = 371
NAIR = 65
NAIR_LANDING = 70
NESS_SHEILD = 372
NESS_SHEILD_AIR = 373
NESS_SHEILD_AIR_END = 375
NESS_SHEILD_START = 372
NEUTRAL_ATTACK_1 = 44
NEUTRAL_ATTACK_2 = 45
NEUTRAL_ATTACK_3 = 46
NEUTRAL_B_ATTACKING = 343
NEUTRAL_B_ATTACKING_AIR = 347
NEUTRAL_B_CHARGING = 342
NEUTRAL_B_CHARGING_AIR = 346
NEUTRAL_B_FULL_CHARGE = 344
NEUTRAL_B_FULL_CHARGE_AIR = 348
NEUTRAL_GETUP = 194
NEUTRAL_TECH = 199
NOTHING_STATE = 11
ON_HALO_DESCENT = 12
ON_HALO_WAIT = 13
PARASOL_FALLING = 370
PARASOL_SWING_1 = 128
PARASOL_SWING_2 = 129
PARASOL_SWING_3 = 130
PARASOL_SWING_4 = 131
PLATFORM_DROP = 244
PUMMELED_HIGH = 225
REBOUND = 238
REBOUND_STOP = 237
ROLL_BACKWARD = 234
ROLL_FORWARD = 233
RUNNING = 21
RUN_BRAKE = 23
RUN_DIRECT = 22
SHIELD = 179
SHIELD_BREAK_DOWN_D = 208
SHIELD_BREAK_DOWN_U = 207
SHIELD_BREAK_FALL = 206
SHIELD_BREAK_FLY = 205
SHIELD_BREAK_STAND_D = 210
SHIELD_BREAK_STAND_U = 209
SHIELD_BREAK_TEETER = 211
SHIELD_REFLECT = 182
SHIELD_RELEASE = 180
SHIELD_START = 178
SHIELD_STUN = 181
SHINE_RELEASE_AIR = 368
SHINE_TURN = 364
SHOULDERED_TURN = 270
SHOULDERED_WAIT = 266
SHOULDERED_WALK_FAST = 269
SHOULDERED_WALK_MIDDLE = 268
SHOULDERED_WALK_SLOW = 267
SLIDING_OFF_EDGE = 251
SPECIAL_FALL_BACK = 37
SPECIAL_FALL_FORWARD = 36
SPOTDODGE = 235
STANDING = 14
STAR_ROD_SWING_1 = 136
STAR_ROD_SWING_2 = 137
STAR_ROD_SWING_3 = 138
STAR_ROD_SWING_4 = 139
SWORD_DANCE_1 = 349
SWORD_DANCE_1_AIR = 358
SWORD_DANCE_2_HIGH = 350
SWORD_DANCE_2_HIGH_AIR = 359
SWORD_DANCE_2_MID = 351
SWORD_DANCE_2_MID_AIR = 360
SWORD_DANCE_3_HIGH = 352
SWORD_DANCE_3_HIGH_AIR = 361
SWORD_DANCE_3_LOW = 354
SWORD_DANCE_3_LOW_AIR = 363
SWORD_DANCE_3_MID = 353
SWORD_DANCE_3_MID_AIR = 362
SWORD_DANCE_4_HIGH = 355
SWORD_DANCE_4_HIGH_AIR = 364
SWORD_DANCE_4_LOW = 357
SWORD_DANCE_4_LOW_AIR = 366
SWORD_DANCE_4_MID = 356
SWORD_DANCE_4_MID_AIR = 365
TAUNT_LEFT = 265
TAUNT_RIGHT = 264
TECH_MISS_DOWN = 191
TECH_MISS_UP = 183
THROWN_BACK = 240
THROWN_COPY_STAR = 291
THROWN_CRAZY_HAND = 339
THROWN_DOWN = 242
THROWN_DOWN_2 = 243
THROWN_FB = 272
THROWN_FF = 271
THROWN_FORWARD = 239
THROWN_F_HIGH = 273
THROWN_F_LOW = 274
THROWN_KIRBY = 292
THROWN_KIRBY_DRINK_S_SHOT = 381
THROWN_KIRBY_SPIT_S_SHOT = 382
THROWN_KIRBY_STAR = 290
THROWN_KOOPA_AIR_B = 287
THROWN_KOOPA_AIR_END_B = 380
THROWN_KOOPA_AIR_END_F = 379
THROWN_KOOPA_AIR_F = 286
THROWN_KOOPA_B = 282
THROWN_KOOPA_END_B = 377
THROWN_KOOPA_END_F = 376
THROWN_KOOPA_F = 281
THROWN_MASTERHAND = 330
THROWN_MEWTWO = 303
THROWN_MEWTWO_AIR = 304
THROWN_UP = 241
THROW_BACK = 220
THROW_DOWN = 222
THROW_FORWARD = 219
THROW_UP = 221
TUMBLING = 38
TURNING = 18
TURNING_RUN = 19
UAIR = 68
UAIR_LANDING = 73
UNKNOWN_ANIMATION = 65535
UPSMASH = 63
UPTILT = 56
UP_B_AIR = 368
UP_B_GROUND = 367
WAIT_ITEM = 345
WALK_FAST = 17
WALK_MIDDLE = 16
WALK_SLOW = 15
WALL_TECH = 202
WALL_TECH_JUMP = 203
WARP_STAP_FALL = 306
WARP_STAR_JUMP = 305
YOSHI_EGG = 277
ZITABATA = 374
class melee.enums.AttackState

Bases: enum.Enum

The phases an attack can be in

ATTACKING = 1
COOLDOWN = 2
NOT_ATTACKING = 3
WINDUP = 0
class melee.enums.Button

Bases: enum.Enum

A single button on a GCN controller NOTE: String values represent the Dolphin input string for that button

BUTTON_A = 'A'
BUTTON_B = 'B'
BUTTON_C = 'C'
BUTTON_D_DOWN = 'D_DOWN'
BUTTON_D_LEFT = 'D_LEFT'
BUTTON_D_RIGHT = 'D_RIGHT'
BUTTON_D_UP = 'D_UP'
BUTTON_L = 'L'
BUTTON_MAIN = 'MAIN'
BUTTON_R = 'R'
BUTTON_START = 'START'
BUTTON_X = 'X'
BUTTON_Y = 'Y'
BUTTON_Z = 'Z'
class melee.enums.Character

Bases: enum.Enum

A Melee character ID. NOTE: Numeric values are ‘internal’ IDs.

BOWSER = 5
CPTFALCON = 2
DK = 3
DOC = 21
FALCO = 22
FOX = 1
GAMEANDWATCH = 24
GANONDORF = 25
GIGA_BOWSER = 31
JIGGLYPUFF = 15
KIRBY = 4
LUIGI = 17
MARIO = 0
MARTH = 18
MEWTWO = 16
NANA = 11
NESS = 8
PEACH = 9
PICHU = 23
PIKACHU = 12
POPO = 10
ROY = 26
SAMUS = 13
SANDBAG = 32
SHEIK = 7
UNKNOWN_CHARACTER = 255
WIREFRAME_FEMALE = 30
WIREFRAME_MALE = 29
YOSHI = 14
ZELDA = 19
class melee.enums.ControllerStatus

Bases: enum.Enum

One of three states a controller can be in during character select

CONTROLLER_CPU = 1
CONTROLLER_HUMAN = 0
CONTROLLER_UNPLUGGED = 3
class melee.enums.ControllerType

Bases: enum.Enum

Types a controller can be in the Dolphin config

GCN_ADAPTER = '12'
STANDARD = '6'
UNPLUGGED = '0'
class melee.enums.Menu

Bases: enum.Enum

A scene the game can be in

CHARACTER_SELECT = 0
IN_GAME = 2
POSTGAME_SCORES = 4
STAGE_SELECT = 1
SUDDEN_DEATH = 3
UNKNOWN_MENU = 255
class melee.enums.ProjectileSubtype

Bases: enum.Enum

Primary type of prejectile or item

ARROW = 64
BEAMSWORD = 12
BOB_OMB = 6
BOWSER_FLAME = 100
DR_MARIO_CAPE = 84
DR_MARIO_CAPSULE = 49
FALCO_LASER = 55
FALCO_SHADOW = 57
FIREFIGHTER = 124
FIRE_ARROW = 65
FOX_LASER = 54
FOX_SHADOW = 56
GW_FIRE = 116
ICE_BLOCK = 106
IC_BLIZZARD = 107
IC_UP_B = 113
JUDGE = 120
KIRBY_BOWSER_FLAME = 154
KIRBY_CUTTER = 50
KIRBY_DR_MARIO_FIRE = 131
KIRBY_FALCO_LASER = 137
KIRBY_FOX_LASER = 136
KIRBY_HAMMER = 51
KIRBY_IC_BLOCK = 133
KIRBY_LUIGI_FIRE = 132
KIRBY_MARIO_FIRE = 130
KIRBY_PICHU_THUNDERJOLT_1 = 149
KIRBY_PICHU_THUNDERJOLT_2 = 150
KIRBY_PIKACHU_THUNDERJOLT_1 = 147
KIRBY_PIKACHU_THUNDERJOLT_2 = 148
KIRBY_PK_FLASH = 145
KIRBY_PK_FLASH_EXPLOSION = 146
KIRBY_SAMUS_CHARGESHOT = 151
KIRBY_SAUSAGE = 155
KIRBY_SHADOWBALL = 144
KIRBY_SHEIK_NEEDLE_GROUND = 153
KIRBY_SHEIK_NEEDLE_THROWN = 152
KIRBY_TOAD_SPORE = 135
KIRBY_YOSHI_TONGUE = 157
LUIGI_FIRE = 105
MANHOLE = 115
MARIO_CAPE = 83
MARIO_FIREBALL = 48
MR_SATURN = 7
NEEDLE_THROWN = 79
NESS_BATT = 101
NESS_YOYO = 102
PARACHUTE = 117
PEACH_PARASOL = 103
PESTICIDE = 114
PICHU_THUNDER = 82
PICHU_THUNDERJOLT_1 = 91
PICHU_THUNDERJOLT_2 = 92
PIKACHU_THUNDER = 81
PIKACHU_THUNDERJOLT_1 = 89
PIKACHU_THUNDERJOLT_2 = 90
PK_FIRE = 66
PK_FLASH_1 = 67
PK_FLASH_2 = 68
PK_FLASH_EXPLOSION = 78
PK_THUNDER_HEAD = 69
PK_THUNDER_TAIL_1 = 70
PK_THUNDER_TAIL_2 = 71
PK_THUNDER_TAIL_3 = 72
PK_THUNDER_TAIL_4 = 73
SAMUS_BOMB = 93
SAMUS_CHARGE_BEAM = 94
SAMUS_GRAPPLE_BEAM = 96
SAMUS_MISSLE = 95
SAUSAGE = 122
SHADOWBALL = 112
SHEIK_CHAIN = 97
SHEIK_SMOKE = 85
SPERKY = 119
TOAD_SPORE = 111
TURNIP = 99
TURTLE = 118
UNKNOWN_PROJECTILE = 255
YOSHI_EGG_THROWN = 86
YOSHI_STAR = 88
YOSHI_TONGUE = 87
ZELDA_FIRE = 108
ZELDA_FIRE_EXPLOSION = 109
class melee.enums.Stage

Bases: enum.Enum

A VS-mode stage

BATTLEFIELD = 24
DREAMLAND = 26
FINAL_DESTINATION = 25
FOUNTAIN_OF_DREAMS = 8
NO_STAGE = 0
POKEMON_STADIUM = 18
RANDOM_STAGE = 29
YOSHIS_STORY = 6
melee.enums.to_internal(char_id)

Converts a character select-screen ID to an ‘internal ID’ enum

melee.framedata module

Helper functions to be able to query Melee frame data in a way useful to bots

class melee.framedata.FrameData(write=False)

Bases: object

Set of helper functions and data structures for knowing Melee frame data The frame data in libmelee is written to be useful to bots, and behave in a sane way, not necessarily be binary-compatible with in-game structures or values.

attack_state(player)

For the given player, returns their current attack state as an AttackState enum

dj_height(character_state)

Returns the height the character’s double jump will take them. If character is in jump already, returns how heigh that one goes

first_hitbox_frame(character, action)

Returns the first frame that a hitbox appears for a given action returns -1 if no hitboxes (not an attack action)

frame_count(character, action)

Returns the count of total frames in the given action.

frames_until_dj_apex(character_state)

Return the number of frames it takes for the character to reach the apex of their double jump. If they haven’t used it yet, then calculate it as if they jumped right now.

hitbox_count(character, action)

Returns the number of hitboxes an attack has

Note

By this we mean is it a multihit attack? (Peach’s down B?) or a single-hit attack? (Marth’s fsmash?)

iasa(character, action)

Returns the first frame of an attack that the character is interruptible (actionable) returns -1 if not an attack

in_range(attacker, defender, stage)

Calculates if an attack is in range of a given defender

Returns:integer with the frame that the specified attack will hit the defender 0 if it won’t hit

Note

This considers the defending character to have a single hurtbox, centered at the x,y coordinates of the player (adjusted up a little to be centered)

is_attack(character, action)

For a given character, is the supplied action an attack?

It is an attack if it has a hitbox at any point in the action. Not necessarily right now.

is_bmove(character, action)

For a given character, is the supplied action a ‘B-Move’

B-Moves tend to be weird, so it’s useful to know if this is a thing that warrants a special case

is_grab(character, action)

For the given character, is the supplied action a grab?

This includes command grabs, such as Bowser’s claw. Not just Z-grabs.

is_roll(character, action)

For a given character, is the supplied action a roll?

Libmelee has a liberal definition of ‘roll’. A roll is essentially a move that:
  1. Has no hitbox
  2. Is inactionable

Some examples of this are SPOTDODGE (Which is basically just a 0-length roll) and taunts.

is_shield(action)

Is the given action a Shielding action?

last_hitbox_frame(character, action)

Returns the last frame that a hitbox appears for a given action returns -1 if no hitboxes (not an attack action)

last_roll_frame(character, action)

Returns the last frame of the roll -1 if not a roll

max_jumps(character)

Returns the number of double-jumps the given character has.

NOTE: This means in general, not according to the current gamestate

range_backward(character, action, frame)

Returns the maximum remaining range of the given attack, in the backwards direction (relative to how the character starts facing) Range “remaining” means that it won’t consider hitboxes that we’ve already passed.

range_forward(character, action, frame)
Returns the maximum remaining range of the given attack, in the forward direction
(relative to how the character starts facing) Range “remaining” means that it won’t consider hitboxes that we’ve already passed.
roll_end_position(character_state, stage)

Returns the x coordinate that the current roll will end in

save_recording()

DEV USE ONLY Saves a recorded frame to the framedata csv

slide_distance(character_state, initspeed, frames)

How far will a character slide, given: character: An enum value of the sliding character initspeed: The initial speed of the character frames: How many frames we want to calculate for

melee.gamestate module

Gamestate is a single snapshot in time of the game that represents all necessary information to make gameplay decisions

class melee.gamestate.GameState(ai_port, opponent_port)

Bases: object

Represents the state of a running game of Melee at a given moment in time

to_list()

Return a list representation of the current gamestate Only caring about in-game things, not menus and such

class melee.gamestate.PlayerState

Bases: object

Represents the state of a single player

to_list()

Produces a list representation of the player’s state

class melee.gamestate.Projectile

Bases: object

Represents the state of a projectile (items, lasers, etc…)

to_list()

Produces a list representation of the projectile

melee.logger module

A custom logger for a console. Writes the gametstate out to a CSV file so you can retroactively view the game frame-by-frame

class melee.logger.Logger

Bases: object

A custom logger for a console. Writes the gametstate out to a CSV file so you can retroactively view the game frame-by-frame

log(column, contents, concat=False)

Write ‘contents’ to the log at given ‘column’

Replaces the contents if concat=False

logframe(gamestate)

Log any common per-frame things

writeframe()

Write the current frame to the log and move to a new frame

writelog()

Write the log to file

melee.menuhelper module

Helper functions for navigating the Melee menus in ways that would be cumbersome to do on your own.

melee.menuhelper.change_controller_status(controller, gamestate, targetport, port, status, character=None)

Switch a given player’s controller to be of the given state

WARNING: There’s a condition on this you need to know. The way controllers work in Melee, if a controller is plugged in, only that player can make the status go to uplugged. If you’ve ever played Melee, you probably know this. If your friend walks away, you have to press the A button on THEIR controller. (or else actually unplug the controller) No way around it.

melee.menuhelper.choose_character(character, gamestate, port, opponent_port, controller, swag=False, start=False)

Choose a character from the character select menu :param character: The character you want to pick :param gamestate: The current gamestate :param controller: The controller object to press :param swag: Pick random until you get the character :param start: Automatically start the match when it’s ready

Note

Intended to be called each frame while in the character select menu

Note

All controller cursors must be above the character level for this to work. The match won’t start otherwise.

melee.menuhelper.choose_stage(stage, gamestate, controller)

Choose a stage from the stage select menu

Intended to be called each frame while in the stage select menu

Parameters:
  • stage – The stage you want to select
  • gamestate – The current gamestate
  • controller – The controller object to press
melee.menuhelper.skip_postgame(controller)

Spam the start button

melee.slippstream module

Implementation of a SlippiComm client aka ‘Slippstream’
(I’m calling it that)

This can be used to talk to some server implementing the Slippstream protocol (i.e. the Project Slippi fork of Nintendont or Slippi Ishiiruka).

class melee.slippstream.CommType

Bases: enum.Enum

Types of SlippiComm messages

HANDSHAKE = 1
KEEPALIVE = 3
MENU = 4
REPLAY = 2
class melee.slippstream.EventType

Bases: enum.Enum

Replay event types

FRAME_BOOKEND = 60
FRAME_START = 58
GAME_END = 57
GAME_START = 54
GECKO_CODES = 16
ITEM_UPDATE = 59
PAYLOADS = 53
POST_FRAME = 56
PRE_FRAME = 55
class melee.slippstream.SlippstreamClient(address='', port=51441, realtime=True)

Bases: object

Container representing a client to some SlippiComm server

connect()

Connect to the server

Returns True on success, False on failure

read_message()

Read an entire message from the registered socket.

Returns None on failure, Dict of data from ubjson on success.

shutdown()

Close down the socket and connection to the console

melee.stages module

Stages is a collection of helper data for information regarding stages

melee.stages.EDGE_POSITION = {<Stage.BATTLEFIELD: 24>: 71.3078536987, <Stage.FINAL_DESTINATION: 25>: 88.4735488892, <Stage.DREAMLAND: 26>: 80.1791534424, <Stage.FOUNTAIN_OF_DREAMS: 8>: 66.2554016113, <Stage.POKEMON_STADIUM: 18>: 90.657852, <Stage.YOSHIS_STORY: 6>: 58.907848}

Get the X coordinate of the edge of the stage, while standing on the stage IE: This is your X coordinate when teetering on the edge NOTE: The left edge is always the same, but negative

melee.techskill module

Helper functions for with some techskill examples

melee.techskill.multishine(ai_state, controller)

Frame-perfect Multishines as Fox

melee.techskill.upsmashes(ai_state, controller)

Spam upsmashes

melee.version module

Version of libmelee

Module contents

Open API written in Python for making your own Smash Bros: Melee AI Python3 only Works on Linux/OSX/Windows