diff --git a/CHANGES.md b/CHANGES.md index 16d9f875..008920db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 0.9.5 + +* zero initialize member variables from base classes + ## 0.9.4 * add random agent script diff --git a/procgen/src/basic-abstract-game.h b/procgen/src/basic-abstract-game.h index 489d6bf4..4036bb13 100644 --- a/procgen/src/basic-abstract-game.h +++ b/procgen/src/basic-abstract-game.h @@ -14,7 +14,7 @@ Base game class used by all currently existing games class BasicAbstractGame : public Game { public: - int grid_size; + int grid_size = 0; BasicAbstractGame(); ~BasicAbstractGame(); @@ -112,31 +112,42 @@ class BasicAbstractGame : public Game { std::vector asset_aspect_ratios; std::vector asset_num_themes; - bool use_procgen_background; - int background_index; - float bg_tile_ratio; - float bg_pct_x; + bool use_procgen_background = false; + int background_index = 0; + float bg_tile_ratio = 0.0f; + float bg_pct_x = 0.0f; - float char_dim; - int last_move_action, move_action, special_action; - float mixrate, maxspeed, max_jump; + float char_dim = 0.0f; + int last_move_action = 0; + int move_action = 0; + int special_action = 0; + float mixrate = 0.0f; + float maxspeed = 0.0f; + float max_jump = 0.0f; - float action_vx; - float action_vy; - float action_vrot; + float action_vx = 0.0f; + float action_vy = 0.0f; + float action_vrot = 0.0f; - float center_x, center_y; + float center_x = 0.0f; + float center_y = 0.0f; bool random_agent_start = true; - bool has_useful_vel_info; - int step_rand_int; + bool has_useful_vel_info = false; + int step_rand_int = 0; RandGen asset_rand_gen; - int main_width, main_height; - int out_of_bounds_object; + int main_width = 0; + int main_height = 0; + int out_of_bounds_object = 0; - float unit, view_dim, x_off, y_off, visibility, min_visibility; + float unit = 0.0f; + float view_dim = 0.0f; + float x_off = 0.0f; + float y_off = 0.0f; + float visibility = 0.0f; + float min_visibility = 0.0f; private: Grid grid; diff --git a/procgen/src/game.h b/procgen/src/game.h index a2e4ab1d..478290e7 100644 --- a/procgen/src/game.h +++ b/procgen/src/game.h @@ -35,9 +35,9 @@ enum DistributionMode { }; struct StepData { - float reward; - bool done; - bool level_complete; + float reward = 0.0f; + bool done = false; + bool level_complete = false; }; struct GameOptions { @@ -61,31 +61,31 @@ class Game { bool grid_step = false; int level_seed_low = 0; int level_seed_high = 1; - int game_type; - int game_n; + int game_type = 0; + int game_n = 0; RandGen level_seed_rand_gen; RandGen rand_gen; StepData step_data; - int action; + int action = 0; - int timeout; + int timeout = 0; - int current_level_seed; - int episodes_remaining; - bool episode_done; + int current_level_seed = 0; + int episodes_remaining = 0; + bool episode_done = false; - float last_ep_reward; - int last_reward_timer; - float last_reward; - int default_action; + float last_ep_reward = 0.0f; + int last_reward_timer = 0; + float last_reward = 0.0f; + int default_action = 0; - int fixed_asset_seed; + int fixed_asset_seed = 0; uint32_t render_buf[RES_W * RES_H]; - int cur_time; + int cur_time = 0; bool is_waiting_for_step = false; @@ -93,8 +93,8 @@ class Game { // these are set by step_async std::vector obs_bufs; std::vector info_bufs; - float *reward_ptr; - uint8_t *done_ptr; + float *reward_ptr = nullptr; + uint8_t *done_ptr = nullptr; Game(); void step(); @@ -109,6 +109,6 @@ class Game { virtual void game_draw(QPainter &p, const QRect &rect) = 0; private: - int reset_count; - float total_reward; + int reset_count = 0; + float total_reward = 0.0f; }; diff --git a/procgen/version.txt b/procgen/version.txt index 2bd77c74..03834411 100644 --- a/procgen/version.txt +++ b/procgen/version.txt @@ -1 +1 @@ -0.9.4 \ No newline at end of file +0.9.5 \ No newline at end of file