#ifndef __STELLA_ENVIRONMENT_HPP__
#define __STELLA_ENVIRONMENT_HPP__
#include "ale_ram.hpp"
#include "ale_screen.hpp"
#include "ale_state.hpp"
#include "phosphor_blend.hpp"
#include "stella_environment_wrapper.hpp"
#include "../emucore/Event.hxx"
#include "../emucore/OSystem.hxx"
#include "../games/RomSettings.hpp"
#include "../common/Constants.h"
#include "../common/Log.hpp"
#include "../common/ScreenExporter.hpp"
#include <cstddef>
#include <stack>
#include <memory>
namespace ale {
class StellaEnvironment {
public:
StellaEnvironment(OSystem* system, RomSettings* settings);
void reset();
void save();
void load();
ALEState cloneState();
void restoreState(const ALEState&);
ALEState cloneSystemState();
void restoreSystemState(const ALEState&);
reward_t act(Action player_a_action, Action player_b_action);
void softReset();
void pressSelect(size_t num_steps = 1);
void setDifficulty(difficulty_t value);
void setMode(game_mode_t value);
bool isTerminal() const;
void setState(const ALEState& state);
const ALEState& getState() const;
const ALEScreen& getScreen() const { return m_screen; }
const ALERAM& getRAM() const { return m_ram; }
int getFrameNumber() const { return m_state.getFrameNumber(); }
int getEpisodeFrameNumber() const { return m_state.getEpisodeFrameNumber(); }
Random& getSystemRng() { return m_osystem->rng(); }
std::unique_ptr<StellaEnvironmentWrapper> getWrapper();
private:
reward_t oneStepAct(Action player_a_action, Action player_b_action);
void emulate(Action player_a_action, Action player_b_action,
size_t num_steps = 1);
void noopIllegalActions(Action& player_a_action, Action& player_b_action);
void processScreen();
void processRAM();
private:
OSystem* m_osystem;
RomSettings* m_settings;
PhosphorBlend m_phosphor_blend; std::string m_cartridge_md5;
std::stack<ALEState> m_saved_states;
ALEState m_state; ALEScreen m_screen; ALERAM m_ram;
bool m_use_paddles;
int m_num_reset_steps; bool m_colour_averaging; int m_max_num_frames_per_episode; size_t m_frame_skip; float m_repeat_action_probability; std::unique_ptr<ScreenExporter> m_screen_exporter;
Action m_player_a_action, m_player_b_action;
};
}
#endif