File indexing completed on 2024-05-26 04:08:33
0001 /* Copyright (C) 2023 Stephan Kulow <coolo@kde.org> 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 */ 0004 0005 #ifndef SPIDERSOLVER2_H 0006 #define SPIDERSOLVER2_H 0007 0008 #include "solverinterface.h" 0009 #include <unordered_map> 0010 class Spider; 0011 class KCardPile; 0012 0013 namespace spidersolver2 0014 { 0015 class Deck; 0016 class MemoryManager; 0017 0018 // how many siblings do we expect for a set of decks (not counting dups) 0019 const int AVG_OPTIONS = 50; 0020 0021 // limit the number of paths to visit in each level 0022 // higher cap mostly finds better solutions (or sometimes some at all), but also takes 0023 // way more time 0024 const int LEVEL_CAP = 150; 0025 0026 class SpiderSolver2 : public SolverInterface 0027 { 0028 public: 0029 SpiderSolver2(Spider *dealer); 0030 ~SpiderSolver2(); 0031 virtual ExitStatus patsolve(int max_positions = -1) override; 0032 virtual void translate_layout() override; 0033 virtual MoveHint translateMove(const MOVE &m) override; 0034 0035 virtual void stopExecution() override; 0036 virtual QList<MOVE> firstMoves() const override 0037 { 0038 return m_firstMoves; 0039 } 0040 virtual QList<MOVE> winMoves() const override 0041 { 0042 return m_winMoves; 0043 } 0044 0045 private: 0046 int solve(); 0047 Spider *m_dealer; 0048 Deck *orig; 0049 QList<MOVE> m_firstMoves; 0050 QList<MOVE> m_winMoves; 0051 MemoryManager *memManager; 0052 }; 0053 } 0054 0055 #endif