spxtr / p3

Super Smash Bros. Melee AI interface for Dolphin.
GNU General Public License v3.0
44 stars 8 forks source link

State callbacks #7

Closed jabdownsmash closed 8 years ago

jabdownsmash commented 8 years ago

Really simple implementation, but effective.

state.players[0].action_state_changed.append(lambda x: print(x.players[0].action_state))
state.frame_changed.append(lambda x: print(x.frame))

To get the dispatchers to pass in the state object rather than the player object in the first line above, I put the handler functions into StateManager. This is a pretty good solution, but there might be a better one. Otherwise, if this looks good I'll write the tests.

spxtr commented 8 years ago

I like the idea here. I'll take a closer look.

spxtr commented 8 years ago

I think I'm going to be a bit simpler and just manually watch this stuff per frame. I don't want to wind up in callback hell :P