Puzzle.hpp
Tools for all puzzle-analysis techniques.
This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2024 Michigan State University MIT Software license; see doc/LICENSE.md
Defines
-
INCLUDE_EMP_GAMES_PUZZLE_HPP_GUARD
-
struct PuzzleMove
- #include <Puzzle.hpp>
Public Functions
-
struct PuzzleSolveFun
- #include <Puzzle.hpp>
-
struct PuzzleProfile
- #include <Puzzle.hpp>
Public Types
Public Functions
-
inline size_t size() const
-
inline bool IsSolved() const
-
inline bool IsUnsolved() const
-
inline bool IsUnsolvable() const
-
inline void AddMoves(size_t level, size_t count)
-
inline void SetSolved()
-
inline void SetUnsolved()
-
inline void SetUnsolvable()
-
inline void Clear()
-
inline size_t CountTypes() const
-
inline size_t CountMoves(size_t id) const
-
inline double CalcScore() const
-
struct Slice
- #include <Puzzle.hpp>
-
inline size_t size() const
-
template<size_t NUM_ROWS, size_t NUM_COLS, size_t NUM_STATES>
struct GridPuzzleAnalyzer - #include <Puzzle.hpp>
A generic analyzer for puzzles that have a set of positions, each in a set of values.
Public Types
-
using move_set_t = vector<PuzzleMove>
Public Functions
-
inline GridPuzzleAnalyzer()
-
virtual ~GridPuzzleAnalyzer() = default
-
inline uint8_t GetValue(size_t cell) const
-
inline bool HasValue(size_t cell) const
-
inline size_t GetNumSolveFuns() const
-
inline uint8_t SymbolToState(char symbol) const
-
inline bool HasOption(size_t cell, uint8_t state) const
Test if a cell is allowed to be a particular state.
-
inline uint8_t FindOption(size_t cell)
Return a currently valid option for provided cell; may not be correct solution.
-
inline bool IsSet(size_t cell) const
-
inline bool IsSolved() const
-
inline void Clear()
Clear out the old solution info when starting a new solve attempt.
-
template<typename FUN_T>
inline void AddSolveFunction(String name, double difficulty, FUN_T fun) Add a function solving method to this puzzle type.
- Parameters:
name – Unique name for this solving technique
difficulty – Difficulty for a human to use this technique
fun – Function to run to perform this technique and return moves
-
inline virtual bool Set(size_t cell, uint8_t state)
Set the value of an individual cell Return true/false based on whether progress was made toward solving the puzzle.
-
inline void Block(size_t cell, uint8_t state)
Remove a symbol option from a particular cell.
-
inline bool MoveProgress(const PuzzleMove &move) const
Identify if a move will make progress in the puzzle.
-
inline bool MoveProgress(const vector<PuzzleMove> &moves) const
Do any of the provided moves progress the puzzle?
-
inline bool Move(const PuzzleMove &move)
Operate on a “move” object; return false if move is invalid.
-
inline bool Move(const vector<PuzzleMove> &moves)
-
inline void PrintMoves(const vector<PuzzleMove> &moves, std::ostream &os = std::cout) const
-
inline bool IsUnsolvable()
-
inline PuzzleProfile CalcProfile()
Public Members
-
array<char, NUM_STATES + 1> symbols
-
array<grid_bits_t, NUM_STATES + 1> bit_options
-
grid_bits_t is_set
-
vector<PuzzleSolveFun> solve_funs
-
using move_set_t = vector<PuzzleMove>