From add27468ed6ee09a9df6f885becc6b0428f666bf Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Fri, 12 Jan 2018 19:03:23 +0000 Subject: Implement symmetrical hash for pile vector --- src/main/game/game_state.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/main/game/game_state.h') diff --git a/src/main/game/game_state.h b/src/main/game/game_state.h index 323646f..8a41398 100644 --- a/src/main/game/game_state.h +++ b/src/main/game/game_state.h @@ -45,12 +45,11 @@ public: 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(card const&); friend std::size_t hash_value(std::vector const&); - friend std::ostream& operator<< (std::ostream&, const game_state&); - private: static std::vector gen_shuffled_deck(int, card::rank_t, bool); -- cgit v1.2.1 From 91442e15dd15f8a4db7455f52255bd46273b0a40 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 18 Jan 2018 13:51:09 +0000 Subject: Update game state with static pile refs & rules --- src/main/game/game_state.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/main/game/game_state.h') diff --git a/src/main/game/game_state.h b/src/main/game/game_state.h index 8a41398..d8e35f3 100644 --- a/src/main/game/game_state.h +++ b/src/main/game/game_state.h @@ -15,12 +15,13 @@ #include "pile.h" #include "sol_rules.h" -class deal_parser; +//class deal_parser; -class game_state { - friend class deal_parser; +// TODO make class +struct game_state { + //friend class deal_parser; friend class state_printer; -public: +//public: // Defines types typedef uint8_t pile_ref; struct move { @@ -34,6 +35,9 @@ public: // Does the same from a 'rules' object game_state(const sol_rules&, int seed); + // For testing + game_state(std::initializer_list); + // Alters state void make_move(move); void undo_move(move); @@ -44,13 +48,13 @@ public: 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(card const&); - friend std::size_t hash_value(std::vector const&); + friend std::size_t hash_value(game_state const&); -private: +//private: + void static_reset(); static std::vector gen_shuffled_deck(int, card::rank_t, bool); // Private constructor @@ -69,18 +73,17 @@ private: card) 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; + static sol_rules rules; + static std::vector tableau_piles; + static std::vector cells; + static pile_ref stock; + static pile_ref waste; + static std::vector reserve; + static std::vector foundations; + static pile_ref hole; // The core piles std::vector piles; }; - #endif //SOLVITAIRE_GAME_STATE_H -- cgit v1.2.1 From 60b86edcba4cd61a0b14aa5e1138a1dd1d7d8718 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 18 Jan 2018 18:57:58 +0000 Subject: Tidy up game_state private access --- src/main/game/game_state.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/main/game/game_state.h') diff --git a/src/main/game/game_state.h b/src/main/game/game_state.h index d8e35f3..8dcffa4 100644 --- a/src/main/game/game_state.h +++ b/src/main/game/game_state.h @@ -15,13 +15,11 @@ #include "pile.h" #include "sol_rules.h" -//class deal_parser; - -// TODO make class -struct game_state { - //friend class deal_parser; +class game_state { + friend class deal_parser; friend class state_printer; -//public: + friend class game_state_pred; +public: // Defines types typedef uint8_t pile_ref; struct move { @@ -53,7 +51,7 @@ struct game_state { friend std::size_t hash_value(card const&); friend std::size_t hash_value(game_state const&); -//private: +private: void static_reset(); static std::vector gen_shuffled_deck(int, card::rank_t, bool); -- cgit v1.2.1