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_INTERFACE_H 0023 #define BOVO_AI_INTERFACE_H 0024 0025 // a coordinate of the table 0026 using pos_T = unsigned char; 0027 // memory allocated for a standing 0028 const pos_T max_table_size = 22; 0029 0030 // a pair of coordinates 0031 struct Field { 0032 pos_T x, y; 0033 Field() 0034 : x(0) 0035 , y(0) 0036 { 0037 } 0038 Field(pos_T x0, pos_T y0) 0039 : x(x0) 0040 , y(y0) 0041 { 0042 } 0043 bool operator==(const Field &field) 0044 { 0045 return x == field.x && y == field.y; 0046 } 0047 }; 0048 0049 class AiInterface; 0050 class AiImpl; 0051 0052 class AiTimeOver 0053 { 0054 public: 0055 virtual ~AiTimeOver() = default; 0056 virtual bool isTimeOver() = 0; 0057 }; 0058 0059 class AiInterface 0060 { 0061 public: 0062 AiInterface(); 0063 virtual ~AiInterface(); 0064 0065 // set a square table with the specified size 0066 void setTableSize(pos_T tableSize); 0067 // set the width of the table 0068 void setTableSizeX(pos_T tableSizeX); 0069 // set the height of the table 0070 void setTableSizeY(pos_T tableSizeY); 0071 0072 // set a fixed depth for the search 0073 void setDepth(int depth); 0074 // set the starting depth for the search 0075 void setStartDepth(int startDepth); 0076 // set the maximum depth for the search 0077 void setMaxDepth(int startDepth); 0078 // set the increment of the depth in every iteration 0079 void setDepthIncrement(int startDepth); 0080 // if set, the AI will think in advance even when he has only one good move 0081 // prevents the AI from wasting thinking time in a competition environment 0082 void setForceThinking(bool forceThinking); 0083 // the amount of random seed added to the heuristic function in every standing 0084 void setRandomAmount(int randomAmount); 0085 // if set, the AI will print information on the standard output 0086 void setPrintInfo(bool printInfo); 0087 // interrupt function, returns true if time is over 0088 void setTimeOver(AiTimeOver *timeOver); 0089 0090 // a new game has started 0091 void newGame(); 0092 // the current player made a step 0093 void step(pos_T x, pos_T y); 0094 // the server made a step 0095 void stepServer(pos_T x, pos_T y); 0096 // undo last move 0097 void undo(); 0098 // suggest a move for the current player 0099 Field think(); 0100 0101 private: 0102 // implementation class 0103 AiImpl *aiImpl; 0104 }; 0105 0106 #endif // BOVO_AI_INTERFACE_H