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 #include "ai_interface.h" 0023 #include "ai_impl.h" 0024 0025 #include <cassert> 0026 0027 AiInterface::AiInterface() 0028 { 0029 aiImpl = new AiImpl(); 0030 } 0031 0032 AiInterface::~AiInterface() 0033 { 0034 delete aiImpl; 0035 } 0036 0037 void AiInterface::setTableSize(pos_T tableSize) 0038 { 0039 assert(5 <= tableSize && tableSize <= max_table_size); 0040 aiImpl->table_size_x = aiImpl->table_size_y = tableSize; 0041 } 0042 0043 void AiInterface::setTableSizeX(pos_T tableSizeX) 0044 { 0045 assert(5 <= tableSizeX && tableSizeX <= max_table_size); 0046 aiImpl->table_size_x = tableSizeX; 0047 } 0048 0049 void AiInterface::setTableSizeY(pos_T tableSizeY) 0050 { 0051 assert(5 <= tableSizeY && tableSizeY <= max_table_size); 0052 aiImpl->table_size_y = tableSizeY; 0053 } 0054 0055 void AiInterface::setDepth(int depth) 0056 { 0057 assert(depth > 0); 0058 aiImpl->start_depth = aiImpl->max_depth = depth; 0059 aiImpl->depth_increment = 2; 0060 } 0061 0062 void AiInterface::setStartDepth(int startDepth) 0063 { 0064 assert(startDepth > 0); 0065 aiImpl->start_depth = startDepth; 0066 if (aiImpl->max_depth < aiImpl->start_depth) 0067 aiImpl->max_depth = aiImpl->start_depth; 0068 } 0069 0070 void AiInterface::setMaxDepth(int maxDepth) 0071 { 0072 assert(maxDepth > 0); 0073 aiImpl->max_depth = maxDepth; 0074 if (aiImpl->start_depth > aiImpl->max_depth) 0075 aiImpl->start_depth = aiImpl->max_depth; 0076 } 0077 0078 void AiInterface::setDepthIncrement(int depthIncrement) 0079 { 0080 assert(depthIncrement > 0); 0081 aiImpl->depth_increment = depthIncrement; 0082 } 0083 0084 void AiInterface::setForceThinking(bool forceThinking) 0085 { 0086 aiImpl->force_thinking = forceThinking; 0087 } 0088 0089 void AiInterface::setRandomAmount(int randomAmount) 0090 { 0091 aiImpl->heur_seed = randomAmount; 0092 } 0093 0094 void AiInterface::setPrintInfo(bool printInfo) 0095 { 0096 aiImpl->print_info = printInfo; 0097 } 0098 0099 void AiInterface::setTimeOver(AiTimeOver *timeOver) 0100 { 0101 assert(timeOver); 0102 aiImpl->timeOver = timeOver; 0103 } 0104 0105 void AiInterface::newGame() 0106 { 0107 aiImpl->newGame(); 0108 } 0109 0110 void AiInterface::step(pos_T x, pos_T y) 0111 { 0112 aiImpl->step(x, y); 0113 } 0114 0115 void AiInterface::stepServer(pos_T x, pos_T y) 0116 { 0117 aiImpl->stepServer(x, y); 0118 } 0119 0120 void AiInterface::undo() 0121 { 0122 aiImpl->undo(); 0123 } 0124 0125 Field AiInterface::think() 0126 { 0127 return aiImpl->think(); 0128 }