// // Created by thecharlesblake on 10/24/17. // #ifndef SOLVITAIRE_GAME_STATE_H #define SOLVITAIRE_GAME_STATE_H #define NULL_MOVE (game_state::move(PILE_REF_MAX, PILE_REF_MAX)) #define PILE_REF_MAX (255) #include #include #include #include #include "card.h" #include "pile.h" #include "sol_rules.h" class deal_parser; class game_state { friend class deal_parser; friend class state_printer; public: // Defines types typedef uint8_t pile_ref; typedef std::pair move; // Constructors // Creates a game state representation from a JSON doc game_state(const sol_rules&, const rapidjson::Document&); // Does the same from a 'rules' object game_state(const sol_rules&, int seed); // Alters state void make_move(move); void undo_move(move); std::vector get_legal_moves() const; // Inspects state bool is_solved() const; const std::vector& get_data() const; friend bool operator==(const game_state&, const game_state&); friend std::ostream& operator<< (std::ostream&, const game_state&); friend std::size_t hash_value(game_state const&); friend std::size_t hash_value(std::vector const&); private: static std::vector gen_shuffled_deck(int, int); // Private constructor explicit game_state(const sol_rules&); // Used in get_legal_moves() bool is_valid_tableau_move(pile_ref, pile_ref) const; bool is_valid_foundations_move(pile_ref, pile_ref) const; bool is_valid_hole_move(pile_ref) const; // References to piles sol_rules rules; std::vector tableau_piles; std::vector cells; pile_ref stock; pile_ref waste; std::vector reserve; std::vector foundations; pile_ref hole; // The core piles std::vector piles; }; #endif //SOLVITAIRE_GAME_STATE_H