def changeaction(state, pos, action):
    """Change the action state on the given position to the new action"""
    rules = state[b'rules']
    assert 0 <= pos < len(rules)
    rules[pos].action = action
