in procgen/src/games/leaper.cpp [122:183]
void game_reset() override {
BasicAbstractGame::game_reset();
options.center_agent = false;
agent->y = agent->ry;
float min_car_speed = 0.05f;
float max_car_speed = 0.2f;
float min_log_speed = 0.05f;
float max_log_speed = 0.1f;
if (options.distribution_mode == EasyMode) {
min_car_speed = 0.03f;
max_car_speed = 0.12f;
min_log_speed = 0.025f;
max_log_speed = 0.075f;
} else if (options.distribution_mode == ExtremeMode) {
min_car_speed = 0.1f;
max_car_speed = 0.3f;
min_log_speed = 0.1f;
max_log_speed = 0.2f;
}
// road
bottom_road_y = choose_extra_space() + 1;
int max_diff = options.distribution_mode == EasyMode ? 3 : 4;
int difficulty = rand_gen.randn(max_diff + 1);
// half the time we add an extra lane to either roads or water
int extra_lane_option = options.distribution_mode == EasyMode ? 0 : rand_gen.randn(4);
int num_road_lanes = difficulty + (extra_lane_option == 2 ? 1 : 0);
road_lane_speeds.clear();
for (int lane = 0; lane < num_road_lanes; lane++) {
road_lane_speeds.push_back(rand_sign() * rand_gen.randrange(min_car_speed, max_car_speed));
fill_elem(0, bottom_road_y + lane, main_width, 1, ROAD);
}
// water
bottom_water_y = bottom_road_y + num_road_lanes + choose_extra_space() + 1;
water_lane_speeds.clear();
int num_water_lanes = difficulty + (extra_lane_option == 3 ? 1 : 0);
int curr_sign = rand_sign();
for (int lane = 0; lane < num_water_lanes; lane++) {
water_lane_speeds.push_back(curr_sign * rand_gen.randrange(min_log_speed, max_log_speed));
curr_sign *= -1;
fill_elem(0, bottom_water_y + lane, main_width, 1, WATER);
}
goal_y = bottom_water_y + num_water_lanes + 1;
// spawn initial entities
for (int i = 0; i < main_width / std::min(min_car_speed, min_log_speed); i++) {
spawn_entities();
step_entities(entities);
}
add_entity_rxy(main_width / 2.0, goal_y - .5, 0, 0, main_width / 2.0, .5, FINISH_LINE);
}