Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding the discrete to continuous action translation #589

Open
k4ntz opened this issue Jan 31, 2025 · 3 comments
Open

Finding the discrete to continuous action translation #589

k4ntz opened this issue Jan 31, 2025 · 3 comments

Comments

@k4ntz
Copy link

k4ntz commented Jan 31, 2025

Hi, I am trying to understand how the inputted action changes the state in Pong and Breakout.
I know that these games were usually controlled using the knob controller (cf here on the right of the image).

Such a controller directly provides the position of the paddle. As ALE uses by default discrete actions, these are translated to continuous ones in this environment. Thus, a state of the Paddle is maintained somewhere. ALE takes in the action, modifies the speed or the acceleration of the Paddle, and thus update the position of the paddle, sent to the game.

I am looking for the function that match this Paddle_state + action to the paddle position.

I have been looking into src/ale/environment/ale_state.cpp, but could not find the matching function.

Do you know where it is executed ?

@pseudo-rnd-thoughts
Copy link
Member

pseudo-rnd-thoughts commented Jan 31, 2025

Why isn't it updatePadlePositions -

void ALEState::updatePaddlePositions(Event* event, int delta_left,

@k4ntz
Copy link
Author

k4ntz commented Jan 31, 2025

Yes, it is called in ALEState::applyActionPaddles.
In short, you have:

      delta_a = static_cast<int>(PADDLE_DELTA * fabs(paddle_a_strength)); 
      updatePaddlePositions(event, delta_a, delta_b);

And in u:

void ALEState::updatePaddlePositions(Event* event, int delta_left,
                                     int delta_right) {
    m_left_paddle += delta_left;
   ...

Thus, I started printing (with cout) the values of delta_left, but they are always constant in my tries (0 for NOOP) or constant for DOWN or UP actions.

I also looked into:

void ALEState::setPaddles(Event* event, int left, int right) {
  m_left_paddle = left;
  m_right_paddle = right;

  // Compute the "resistance" (this is for vestigal clarity)
  int left_resistance = calcPaddleResistance(m_left_paddle);
  int right_resistance = calcPaddleResistance(m_right_paddle);

  // Update the events with the new resistances
  event->set(Event::PaddleZeroResistance, left_resistance);
  event->set(Event::PaddleOneResistance, right_resistance);
}

But it seems that this resistance is then never used. As the delta I see applied are constant.

@pseudo-rnd-thoughts
Copy link
Member

Shouldn't you care about m_left_paddle and m_right_paddle rather than the delta as this is the amount that the paddles move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants