Skip to content

Commit

Permalink
reduce to minimal action set
Browse files Browse the repository at this point in the history
  • Loading branch information
jjshoots committed Dec 15, 2024
1 parent 77fe8ef commit f0b83e3
Show file tree
Hide file tree
Showing 113 changed files with 1,609 additions and 1,688 deletions.
2 changes: 1 addition & 1 deletion src/ale/ale_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ALEInterface {
reward_t act(
Action a_action,
float a_paddle_strength = 1.0,
Action b_action = PLAYER_B_NOOP,
Action b_action = NOOP,
float b_paddle_strength = 0.0
);

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

0 comments on commit f0b83e3

Please sign in to comment.