Skip to main content
. 2024 Jun 8;9(6):346. doi: 10.3390/biomimetics9060346
Algorithm 1 Modified HER Algorithm for Retaining Experience with Adjusted Rewards
  •   1:

    Initialize environment and agent

  •   2:

    state_history←[]

  •   3:

    fallen_index←−1

  •   4:

    while task not finished do

  •   5:

        action←agentselectsaction(current_state)

  •   6:

        next_state,reward,done,info←environmentexecutesaction(action)

  •   7:

        Append current_state to state_history

  •   8:

        if info[‘fallen’]=True then

  •   9:

            done←True

  • 10:

          fallen_index←length(state_history)

  • 11:

      end if

  • 12:

      current_state←next_state

  • 13:

    end while

  • 14:

    if fallen_index≥20  then

  • 15:

       successful_states←state_history[0:fallen_index−20]

  • 16:

       last_actions←state_history[fallen_index−20:fallen_index]

  • 17:

      Add a reward of 10 to the reward of successful_states

  • 18:

      Process successful_states for further learning as successful attempts

  • 19:

      Store last_actions in experience pool without additional reward

  • 20:

    end if