class OthelloEnv(MultiTurnEnv): def env_response(self, model_output, state): move = parse_move(model_output) if not is_valid(move, state.board): state.penalty += INVALID_MOVE_PENALTY return error_message(move), state # same turn, retry state.board = apply_move(state.board, move, player="black") if not game_over(state.board): white_move = opponent_engine(state.board, state.difficulty) state.board = apply_move(state.board, white_move, player="white") return render_board(state.board), state