Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ale/ale_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bool ALEInterface::game_over(bool with_truncation) const {
return with_truncation ? environment->isTerminal() : environment->isGameTerminal();
}

// Indicateds if the episode has been truncated.
// Indicates if the episode has been truncated.
bool ALEInterface::game_truncated() const { return environment->isGameTruncated(); }

// The remaining number of lives.
Expand All @@ -259,9 +259,13 @@ int ALEInterface::lives() {
// user's responsibility to check if the game has ended and reset
// when necessary - this method will keep pressing buttons on the
// game over screen.
// Intentionally set player B actions to 0 since we are in single player mode
reward_t ALEInterface::act(Action action, float paddle_strength) {
return environment->act(action, PLAYER_B_NOOP, paddle_strength, 0.0);
reward_t ALEInterface::act(
Action a_action,
float a_paddle_strength,
Action b_action,
float b_paddle_strength
) {
return environment->act(a_action, b_action, a_paddle_strength, b_paddle_strength);
}

// Returns the vector of modes available for the current game.
Expand Down
7 changes: 6 additions & 1 deletion src/ale/ale_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ class ALEInterface {
// user's responsibility to check if the game has ended and reset
// when necessary - this method will keep pressing buttons on the
// game over screen.
reward_t act(Action action, float paddle_strength = 1.0);
reward_t act(
Action a_action,
float a_paddle_strength = 1.0,
Action b_action = NOOP,
float b_paddle_strength = 0.0
);

// Indicates if the game has ended.
bool game_over(bool with_truncation = true) const;
Expand Down
70 changes: 26 additions & 44 deletions src/ale/common/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,33 @@ namespace ale {

std::string action_to_string(Action a) {
static std::string tmp_action_to_string[] = {
"PLAYER_A_NOOP",
"PLAYER_A_FIRE",
"PLAYER_A_UP",
"PLAYER_A_RIGHT",
"PLAYER_A_LEFT",
"PLAYER_A_DOWN",
"PLAYER_A_UPRIGHT",
"PLAYER_A_UPLEFT",
"PLAYER_A_DOWNRIGHT",
"PLAYER_A_DOWNLEFT",
"PLAYER_A_UPFIRE",
"PLAYER_A_RIGHTFIRE",
"PLAYER_A_LEFTFIRE",
"PLAYER_A_DOWNFIRE",
"PLAYER_A_UPRIGHTFIRE",
"PLAYER_A_UPLEFTFIRE",
"PLAYER_A_DOWNRIGHTFIRE",
"PLAYER_A_DOWNLEFTFIRE",
"PLAYER_B_NOOP",
"PLAYER_B_FIRE",
"PLAYER_B_UP",
"PLAYER_B_RIGHT",
"PLAYER_B_LEFT",
"PLAYER_B_DOWN",
"PLAYER_B_UPRIGHT",
"PLAYER_B_UPLEFT",
"PLAYER_B_DOWNRIGHT",
"PLAYER_B_DOWNLEFT",
"PLAYER_B_UPFIRE",
"PLAYER_B_RIGHTFIRE",
"PLAYER_B_LEFTFIRE",
"PLAYER_B_DOWNFIRE",
"PLAYER_B_UPRIGHTFIRE",
"PLAYER_B_UPLEFTFIRE",
"PLAYER_B_DOWNRIGHTFIRE",
"PLAYER_B_DOWNLEFTFIRE",
"__invalid__", // 36
"__invalid__", // 37
"__invalid__", // 38
"__invalid__", // 39
"RESET", // 40
"UNDEFINED", // 41
"RANDOM", // 42
"NOOP",
"FIRE",
"UP",
"RIGHT",
"LEFT",
"DOWN",
"UPRIGHT",
"UPLEFT",
"DOWNRIGHT",
"DOWNLEFT",
"UPFIRE",
"RIGHTFIRE",
"LEFTFIRE",
"DOWNFIRE",
"UPRIGHTFIRE",
"UPLEFTFIRE",
"DOWNRIGHTFIRE",
"DOWNLEFTFIRE",
"RESET", // 18
"UNDEFINED", // 19
"RANDOM", // 20
"__invalid__", // 21
"__invalid__", // 22
"__invalid__", // 23
"__invalid__", // 24
};
assert(a >= 0 && a <= 42);
assert(a >= 0 && a <= 24);
return tmp_action_to_string[a];
}

Expand Down
71 changes: 26 additions & 45 deletions src/ale/common/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,34 @@ namespace ale {

// Define actions
enum Action {
PLAYER_A_NOOP = 0,
PLAYER_A_FIRE = 1,
PLAYER_A_UP = 2,
PLAYER_A_RIGHT = 3,
PLAYER_A_LEFT = 4,
PLAYER_A_DOWN = 5,
PLAYER_A_UPRIGHT = 6,
PLAYER_A_UPLEFT = 7,
PLAYER_A_DOWNRIGHT = 8,
PLAYER_A_DOWNLEFT = 9,
PLAYER_A_UPFIRE = 10,
PLAYER_A_RIGHTFIRE = 11,
PLAYER_A_LEFTFIRE = 12,
PLAYER_A_DOWNFIRE = 13,
PLAYER_A_UPRIGHTFIRE = 14,
PLAYER_A_UPLEFTFIRE = 15,
PLAYER_A_DOWNRIGHTFIRE = 16,
PLAYER_A_DOWNLEFTFIRE = 17,
PLAYER_B_NOOP = 18,
PLAYER_B_FIRE = 19,
PLAYER_B_UP = 20,
PLAYER_B_RIGHT = 21,
PLAYER_B_LEFT = 22,
PLAYER_B_DOWN = 23,
PLAYER_B_UPRIGHT = 24,
PLAYER_B_UPLEFT = 25,
PLAYER_B_DOWNRIGHT = 26,
PLAYER_B_DOWNLEFT = 27,
PLAYER_B_UPFIRE = 28,
PLAYER_B_RIGHTFIRE = 29,
PLAYER_B_LEFTFIRE = 30,
PLAYER_B_DOWNFIRE = 31,
PLAYER_B_UPRIGHTFIRE = 32,
PLAYER_B_UPLEFTFIRE = 33,
PLAYER_B_DOWNRIGHTFIRE = 34,
PLAYER_B_DOWNLEFTFIRE = 35,
RESET = 40, // MGB: Use SYSTEM_RESET to reset the environment.
UNDEFINED = 41,
RANDOM = 42,
SAVE_STATE = 43,
LOAD_STATE = 44,
SYSTEM_RESET = 45,
LAST_ACTION_INDEX = 50
NOOP = 0,
FIRE = 1,
UP = 2,
RIGHT = 3,
LEFT = 4,
DOWN = 5,
UPRIGHT = 6,
UPLEFT = 7,
DOWNRIGHT = 8,
DOWNLEFT = 9,
UPFIRE = 10,
RIGHTFIRE = 11,
LEFTFIRE = 12,
DOWNFIRE = 13,
UPRIGHTFIRE = 14,
UPLEFTFIRE = 15,
DOWNRIGHTFIRE = 16,
DOWNLEFTFIRE = 17,
RESET = 18, // MGB: Use SYSTEM_RESET to reset the environment.
UNDEFINED = 19,
RANDOM = 20,
SAVE_STATE = 21,
LOAD_STATE = 22,
SYSTEM_RESET = 23,
LAST_ACTION_INDEX = 24
};

#define PLAYER_A_MAX (18)
#define PLAYER_B_MAX (36)
#define ACTION_MAX (18)

std::string action_to_string(Action a);

Expand Down
Loading
Loading