altf4 / libmelee

Open Python 3 API for making your own Smash Bros: Melee AI that works with Slippi Online
GNU Lesser General Public License v3.0
237 stars 47 forks source link

Gamestate shows wrong analog values for controller state #65

Closed wong-justin closed 3 years ago

wong-justin commented 3 years ago

A controller.current should be the same as gamestate.player[port].controller_state for any given frame, but the sticks and trigger values don't match.

Sample logs during a frame: From controller: (<Button.BUTTON_MAIN: 'MAIN'>, 0.45, 0.62) (<Button.BUTTON_L: 'L'>, 0.52) Button.BUTTON_A From gamestate: (<Button.BUTTON_MAIN: 'MAIN'>, 0.5, 0.6875) (<Button.BUTTON_L: 'L'>, 0) Button.BUTTON_A

I set random values for the main stick and L trigger at the beginning of a match. The controller state read directly from the controller matches those values as expected, but from the gamestate it's mostly wrong. The stick coords are roughly close, and the trigger just stays 0. The other digital buttons seem to be recorded fine (eg. A).

Tested with ports 1 and 2 on v0.20.2.

altf4 commented 3 years ago

What you're seeing is the difference between physical inputs and processed inputs. This is expected.

controller.current is the physical inputs that you've queued up, but haven't sent yet.

gamestate.player[port].controller_state is the processed inputs for that same frame.