state pattern self jumping jumping(selfself crouching crouching(selfself mapping " "self running_left" "self running_right" "self crouching" "self jumping"default"self standingself state self standing def action(selfin_key)self state switch(in_keydef __str__(self)return str(self statedef main()player statemachine(win curses initscr(curses noecho(win addstr( "press the keys to initiate actions"win addstr( "press to exit"win addstr( ""win move( while truech win getch(if ch is not nonewin move( win deleteln(win addstr( ""if ch = break