File indexing completed on 2024-11-24 03:43:17

0001 /*******************************************************************
0002  *
0003  * This file is part of the KDE project "Bovo"
0004  *
0005  * Bovo is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2, or (at your option)
0008  * any later version.
0009  *
0010  * Bovo is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with Bovo; see the file COPYING.  If not, write to
0017  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  *
0020  ********************************************************************/
0021 
0022 #ifndef BOVO_AI_IMPL_H
0023 #define BOVO_AI_IMPL_H
0024 
0025 #include "ai_interface.h"
0026 #include "standing.h"
0027 
0028 #include <list>
0029 
0030 using previous_standings_T = std::list<Standing>;
0031 
0032 class AiImpl
0033 {
0034 public:
0035     AiImpl();
0036     virtual ~AiImpl();
0037 
0038     // the width of the table
0039     pos_T table_size_x;
0040     // the height of the table
0041     pos_T table_size_y;
0042     // the starting depth for the search
0043     int start_depth;
0044     // the maximum depth for the search
0045     int max_depth;
0046     // the increment of the depth in every iteration
0047     int depth_increment;
0048     // if set, the AI will think in advance even when he has only one good move
0049     // prevents the AI from wasting thinking time in a competition environment
0050     bool force_thinking;
0051     // the amount of random seed added to the heuristic function in every standing
0052     heur_T heur_seed;
0053     // if set, the AI will print information on the standard output
0054     bool print_info;
0055     // limits the amount of following steps to be investigated from a standing
0056     unsigned int max_branch;
0057 
0058     // interrupt class, returns true if time is over
0059     AiTimeOver *timeOver;
0060 
0061     // current search depth limit
0062     int depth_limit;
0063 
0064     // a new game has started
0065     void newGame();
0066     // the current player made a step
0067     void step(pos_T x, pos_T y);
0068     // the server made a step
0069     void stepServer(pos_T x, pos_T y);
0070     // undo last move
0071     void undo();
0072     // suggest a move for the current player
0073     Field think();
0074 
0075 private:
0076     // the standing persisted across steps
0077     Standing rememberedStanding;
0078     // the game history for undo
0079     previous_standings_T previousStandings;
0080     // suggest a move for the current player from the opening book
0081     Field openingBook();
0082 };
0083 
0084 #endif // BOVO_AI_IMPL_H