File indexing completed on 2024-06-16 03:56:49

0001 /*
0002  * Copyright (C) 2006-2009 Stephan Kulow <coolo@kde.org>
0003  *
0004  * This program is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU General Public License as
0006  * published by the Free Software Foundation; either version 2 of
0007  * the License, or (at your option) any later version.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  * GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License
0015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef GOLFSOLVER_H
0019 #define GOLFSOLVER_H
0020 
0021 #include "solverinterface.h"
0022 // black-hole-solver
0023 #include <black-hole-solver/black_hole_solver.h>
0024 
0025 class Golf;
0026 
0027 class GolfSolver : public SolverInterface
0028 {
0029 public:
0030     GolfSolver(const Golf *dealer);
0031     ~GolfSolver()
0032     {
0033     }
0034     int default_max_positions;
0035 
0036     SolverInterface::ExitStatus patsolve(int max_positions = -1) override;
0037     void translate_layout() override;
0038     MoveHint translateMove(const MOVE &m) override;
0039     void stopExecution() override;
0040     QList<MOVE> firstMoves() const override
0041     {
0042         return QList<MOVE>();
0043     }
0044     QList<MOVE> winMoves() const override
0045     {
0046         return m_winMoves;
0047     }
0048 
0049 private:
0050     const Golf *deal;
0051 
0052     black_hole_solver_instance_t *solver_instance;
0053     int solver_ret;
0054     // More than enough space for two decks.
0055     char board_as_string[4 * 13 * 2 * 4 * 3];
0056     void free_solver_instance();
0057 
0058     QList<MOVE> m_winMoves;
0059 };
0060 
0061 #endif // GOLFSOLVER_H