1 /*******************************************************************
2 *
3 * This file is part of the KDE project "Bovo"
4 *
5 * Bovo is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * Bovo is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Bovo; see the file COPYING. If not, write to
17 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 ********************************************************************/
21
22
23 #include "ai_interface.h"
24 #include "ai_impl.h"
25
26 #include <assert.h>
27
AiInterface()28 AiInterface::AiInterface() {
29 aiImpl = new AiImpl();
30 }
31
~AiInterface()32 AiInterface::~AiInterface() {
33 delete aiImpl;
34 }
35
setTableSize(pos_T tableSize)36 void AiInterface::setTableSize(pos_T tableSize) {
37 assert(5 <= tableSize && tableSize <= max_table_size);
38 aiImpl->table_size_x = aiImpl->table_size_y = tableSize;
39 }
40
setTableSizeX(pos_T tableSizeX)41 void AiInterface::setTableSizeX(pos_T tableSizeX) {
42 assert(5 <= tableSizeX && tableSizeX <= max_table_size);
43 aiImpl->table_size_x = tableSizeX;
44 }
45
setTableSizeY(pos_T tableSizeY)46 void AiInterface::setTableSizeY(pos_T tableSizeY) {
47 assert(5 <= tableSizeY && tableSizeY <= max_table_size);
48 aiImpl->table_size_y = tableSizeY;
49 }
50
setDepth(int depth)51 void AiInterface::setDepth(int depth) {
52 assert(depth > 0);
53 aiImpl->start_depth = aiImpl->max_depth = depth;
54 aiImpl->depth_increment = 2;
55 }
56
setStartDepth(int startDepth)57 void AiInterface::setStartDepth(int startDepth) {
58 assert(startDepth > 0);
59 aiImpl->start_depth = startDepth;
60 if (aiImpl->max_depth < aiImpl->start_depth)
61 aiImpl->max_depth = aiImpl->start_depth;
62 }
63
setMaxDepth(int maxDepth)64 void AiInterface::setMaxDepth(int maxDepth) {
65 assert(maxDepth > 0);
66 aiImpl->max_depth = maxDepth;
67 if (aiImpl->start_depth > aiImpl->max_depth)
68 aiImpl->start_depth = aiImpl->max_depth;
69 }
70
setDepthIncrement(int depthIncrement)71 void AiInterface::setDepthIncrement(int depthIncrement) {
72 assert(depthIncrement > 0);
73 aiImpl->depth_increment = depthIncrement;
74 }
75
setForceThinking(bool forceThinking)76 void AiInterface::setForceThinking(bool forceThinking) {
77 aiImpl->force_thinking = forceThinking;
78 }
79
setRandomAmount(int randomAmount)80 void AiInterface::setRandomAmount(int randomAmount) {
81 aiImpl->heur_seed = randomAmount;
82 }
83
setPrintInfo(bool printInfo)84 void AiInterface::setPrintInfo(bool printInfo) {
85 aiImpl->print_info = printInfo;
86 }
87
setTimeOver(AiTimeOver * timeOver)88 void AiInterface::setTimeOver(AiTimeOver* timeOver) {
89 assert(timeOver);
90 aiImpl->timeOver = timeOver;
91 }
92
newGame()93 void AiInterface::newGame() {
94 aiImpl->newGame();
95 }
96
step(pos_T x,pos_T y)97 void AiInterface::step(pos_T x, pos_T y) {
98 aiImpl->step(x, y);
99 }
100
stepServer(pos_T x,pos_T y)101 void AiInterface::stepServer(pos_T x, pos_T y) {
102 aiImpl->stepServer(x, y);
103 }
104
undo()105 void AiInterface::undo() {
106 aiImpl->undo();
107 }
108
think()109 Field AiInterface::think() {
110 return aiImpl->think();
111 }
112