agent sarsa rewrite