From 8c819b9e127d6ca837da214667945634725a66ed Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 16 Nov 2018 11:09:45 +0000 Subject: wow a thing that works --- src/main/api.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/api.h (limited to 'src/main/api.h') diff --git a/src/main/api.h b/src/main/api.h new file mode 100644 index 0000000..86e3441 --- /dev/null +++ b/src/main/api.h @@ -0,0 +1,66 @@ +#include +#include +#include +#include + +#include "game/move.h" +#include "game/sol_rules.h" + +// just for now, until I construct my own rules stuff: +#include "input-output/input/json-parsing/rules_parser.h" + +typedef std::vector> piles; +typedef std::vector movelist; + +class game_state { + public: + game_state(const sol_rules&, piles); + enum class streamliner_options {NONE, AUTO_FOUNDATIONS, SUIT_SYMMETRY, BOTH}; + void make_move(move); + + friend std::ostream& operator<< (std::ostream&, const game_state&); + + private: + /* Game rules */ + + const sol_rules rules; + streamliner_options stream_opts; + card::rank_t foundations_base; + + /* Pile references */ + + std::list tableau_piles; + std::list cells; + pile::ref stock; + pile::ref waste; + std::list reserve; + std::vector foundations; + std::vector sequences; + std::list accordion; + pile::ref hole; + + /* Pile references of starting/original layout */ + + std::vector original_tableau_piles; + std::vector original_cells; + std::vector original_reserve; + + /* Auto-foundation moves state */ + + std::vector auto_foundation_moves; + + /* Core piles */ + + std::vector piles; +}; + +/** + * Populate a move list with a bunch of moves that lead to a solution. + * + * Clears the list, then, if a solution is found, populates it with the moves + * required to realise the solution. + * + * Returns true if a solution was found; false otherwise. + */ +bool get_moves(movelist& moves, game_state& gs, uint64_t cache_capacity, + uint64_t timeout); -- cgit v1.2.1