void BasicAbstractGame::game_step()

in procgen/src/basic-abstract-game.cpp [686:746]


void BasicAbstractGame::game_step() {
    step_rand_int = rand_gen.randint(0, 1000000);
    move_action = action % 9;
    special_action = 0;

    if (action >= 9) {
        special_action = action - 8;
        move_action = 4; // stand still when taking a special action
    }

    if (move_action != 4) {
        last_move_action = move_action;
    }

    // set reasonable defaults
    action_vrot = 0;
    action_vx = 0;
    action_vy = 0;

    set_action_xy(move_action);

    if (grid_step) {
        agent->vx = action_vx;
        agent->vy = action_vy;
    } else {
        update_agent_velocity();

        agent->vrot = MIXRATEROT * agent->vrot;
        agent->vrot += MIXRATEROT * MAXVTHETA * action_vrot;
    }

    step_entities(entities);

    for (int i = (int)(entities.size()) - 1; i >= 0; i--) {
        auto ent = entities[i];

        if (has_agent_collision(ent)) {
            handle_agent_collision(ent);
        }

        if (ent->collides_with_entities) {
            for (int j = (int)(entities.size()) - 1; j >= 0; j--) {
                if (i == j)
                    continue;
                auto ent2 = entities[j];

                if (has_collision(ent, ent2, ent->collision_margin) && !ent->will_erase && !ent2->will_erase) {
                    handle_collision(ent, ent2);
                }
            }
        }

        if (ent->smart_step) {
            check_grid_collisions(ent);
        }
    }

    erase_if_needed();

    step_data.done = step_data.done || is_out_of_bounds(agent);
}