| 1 | /*************************************************************************** |
| 2 | qgtp.cpp - description |
| 3 | ------------------- |
| 4 | begin : Thu Nov 29 2001 |
| 5 | copyright : (C) 2001 by PALM Thomas , DINTILHAC Florian, HIVERT Anthony, PIOC Sebastien |
| 6 | email : |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | /*************************************************************************** |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | //#include <unistd.h> |
| 21 | #include <stdlib.h> |
| 22 | #include <QApplication> |
| 23 | #include <QDebug> |
| 24 | enum CommandTypecxx . . $ CommandType# {PROTOCOLcxx . . $ PROTOCOL., BOARDSIZEcxx . . $ BOARDSIZE., KNOWN_COMMANDcxx . . $ KNOWN_COMMAND., LEVELcxx . . $ LEVEL., KOMIcxx . . $ KOMI., PLAY_BLACKcxx . . $ PLAY_BLACK., PLAY_WHITEcxx . . $ PLAY_WHITE., GENMOVEcxx . . $ GENMOVE.}; |
| 25 | #include "qgtp.h"cxx . . $ `<file>/src/gtp/qgtp.h`/ |
| 26 | |
| 27 | #ifdef Q_OS_WIN |
| 28 | #include <Windows.h> |
| 29 | #endif |
| 30 | |
| 31 | /* Function: open a session |
| 32 | * Arguments: name and path of go program |
| 33 | * Fails: never |
| 34 | * Returns: nothing |
| 35 | */ |
| 36 | QGtpcxx . . $ QGtp#::QGtpcxx . . $ QGtp#QGtp(49f6e7a06ebc5aa8).() |
| 37 | { |
| 38 | /*openGtpSession(filename);*/ |
| 39 | programProcesscxx . . $ QGtp#programProcess. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; // This to permit proper ending |
| 40 | responseReceivedcxx . . $ QGtp#responseReceived. = false; |
| 41 | answercxx . . $ QGtp#answer. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 42 | busycxx . . $ QGtp#busy. = false; |
| 43 | } |
| 44 | |
| 45 | QGtpcxx . . $ QGtp#::~cxx . . $ QGtp#`~QGtp`(ced63f7c635d850d).QGtpcxx . . $ QGtp#() |
| 46 | { |
| 47 | if (programProcesscxx . . $ QGtp#programProcess.) |
| 48 | programProcesscxx . . $ QGtp#programProcess.->killcxx . . $ QProcess#kill(49f6e7a06ebc5aa8).(); // not very clean (should use tryTerminate) |
| 49 | } |
| 50 | |
| 51 | /* Code */ |
| 52 | |
| 53 | /* Function: get the last message from gnugo |
| 54 | * Arguments: none |
| 55 | * Fails: never |
| 56 | * Returns: last message from GO |
| 57 | */ |
| 58 | |
| 59 | |
| 60 | QStringcxx . . $ QString# QGtpcxx . . $ QGtp#::getLastMessagecxx . . $ QGtp#getLastMessage(4365c3963150523e).() |
| 61 | { |
| 62 | return _responsecxx . . $ QString#QString(132dd6869045752b).; |
| 63 | } |
| 64 | |
| 65 | int QGtpcxx . . $ QGtp#::openGtpSessioncxx . . $ QGtp#openGtpSession(18a8b0c0b3bf543a).(QStringcxx . . $ QString# path, QStringcxx . . $ QString# args, int size, float komi, int handicap) |
| 66 | { |
| 67 | _cptcxx . . $ QGtp#_cpt. = 1000; |
| 68 | |
| 69 | programProcesscxx . . $ QGtp#programProcess. = new QProcesscxx . . $ QProcess#(); |
| 70 | programProcesscxx . . $ QGtp#programProcess.->setReadChannelcxx . . $ QProcess#setReadChannel(bf19820e89ffcdec).(QProcesscxx . . $ QProcess#::StandardOutputcxx . . $ QProcess#StandardOutput.); |
| 71 | QStringListcxx . . $ QStringList# arguments = args.splitcxx . . $ QString#split(2ba03f79dd8e9c12).(' 'cxx . . $ QChar#QChar(f349c77f591a7878).,QStringcxx . . $ QString#::SkipEmptyPartscxx . . $ QString#SkipEmptyParts.); |
| 72 | issueCmdNbcxx . . $ QGtp#issueCmdNb. = false; |
| 73 | |
| 74 | if (path.containscxx . . $ QString#contains(493fc6ca23db3119).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("gnugo$"cxx . . $ QString#QString(85c52e162fed56f9)., Qtcxx . . $ Qt/::CaseInsensitivecxx . . $ Qt/CaseInsensitive.))) |
| 75 | issueCmdNbcxx . . $ QGtp#issueCmdNb. = true; // FIXME: are command numbers really gnugo-specific? |
| 76 | |
| 77 | connectcxx . . $ QObject#connect(835f87066c895669).(programProcesscxx . . $ QGtp#programProcess., &QProcesscxx . . $ QProcess#::readyReadcxx . . $ QIODevice#readyRead(49f6e7a06ebc5aa8)., this, &QGtpcxx . . $ QGtp#::slot_readFromStdoutcxx . . $ QGtp#slot_readFromStdout(49f6e7a06ebc5aa8).); |
| 78 | connectcxx . . $ QObject#connect(835f87066c895669).(programProcesscxx . . $ QGtp#programProcess., QOverloadcxx . . $ QOverload#<int,QProcess::ExitStatus>::ofcxx . . $ QOverload#of(8e142c06a530e2ab).(&QProcesscxx . . $ QProcess#::finishedcxx . . $ QProcess#finished(15c350e1a5203cbf).), this, &QGtpcxx . . $ QGtp#::slot_processExitedcxx . . $ QGtp#slot_processExited(15c350e1a5203cbf).); |
| 79 | |
| 80 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "QGtp::openGtpSession(" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). path <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "," <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). args <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ")"; |
| 81 | |
| 82 | programProcesscxx . . $ QGtp#programProcess.->startcxx . . $ QProcess#start(5e315ba9c811784d).(path, arguments); |
| 83 | |
| 84 | |
| 85 | if (!programProcesscxx . . $ QGtp#programProcess.->waitForStartedcxx . . $ QProcess#waitForStarted(83c267b20bac841a).()) |
| 86 | { |
| 87 | _responsecxx . . $ QGtp#_response.=cxx . . $ QString#`operator=`(b79fde0b0ce9b948)."Could not start "+cxx . . $ operator+(c75c3ae4eb9af1a8).path; |
| 88 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`! ; |
| 89 | } |
| 90 | |
| 91 | //?? never know ... otherwise, I get a segfault with sprint ... |
| 92 | if ((outFilecxx . . $ QGtp#outFile. = (char *)malloccxx . . $ malloc(9f008b2a9698428b). (100)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 93 | { |
| 94 | _responsecxx . . $ QGtp#_response.=cxx . . $ QString#`operator=`(d02845eef0c33901)."Yuck ! Could not allocate 100 bytes !!!" ; |
| 95 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`! ; |
| 96 | } |
| 97 | |
| 98 | if (protocolVersioncxx . . $ QGtp#protocolVersion(b126dc7c1de90089).()==OKcxx . . $ `src/gtp/qgtp.h:25:9`!) |
| 99 | { |
| 100 | if(getLastMessagecxx . . $ QGtp#getLastMessage(4365c3963150523e).().toIntcxx . . $ QString#toInt(d7972accae11ee1f).() !=2) |
| 101 | { |
| 102 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Protocol version problem???"); |
| 103 | // quit(); |
| 104 | _responsecxx . . $ QGtp#_response.=cxx . . $ QString#`operator=`(d02845eef0c33901)."Protocol version not supported"; |
| 105 | // return FAIL; |
| 106 | } |
| 107 | if(setBoardsizecxx . . $ QGtp#setBoardsize(7864480464b09eea).(size)==FAILcxx . . $ `src/gtp/qgtp.h:26:9`!) |
| 108 | { |
| 109 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`!; |
| 110 | } |
| 111 | if(clearBoardcxx . . $ QGtp#clearBoard(b126dc7c1de90089).()==FAILcxx . . $ `src/gtp/qgtp.h:26:9`!) |
| 112 | { |
| 113 | // removed by frosla -> protocol changes... |
| 114 | // return FAIL; |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | if(knownCommand("level")==FAIL) |
| 119 | { |
| 120 | return FAIL; |
| 121 | } |
| 122 | |
| 123 | else if (getLastMessage().contains("true")) |
| 124 | { |
| 125 | if (setLevel(level)==FAIL) |
| 126 | { |
| 127 | return FAIL; |
| 128 | } |
| 129 | } |
| 130 | */ |
| 131 | |
| 132 | if(setKomicxx . . $ QGtp#setKomi(1bb0578f3efdc255).(komi)==FAILcxx . . $ `src/gtp/qgtp.h:26:9`!) |
| 133 | { |
| 134 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`!; |
| 135 | } |
| 136 | |
| 137 | if(fixedHandicapcxx . . $ QGtp#fixedHandicap(7864480464b09eea).(handicap)==FAILcxx . . $ `src/gtp/qgtp.h:26:9`!) |
| 138 | { |
| 139 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`!; |
| 140 | } |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | quitcxx . . $ QGtp#quit(b126dc7c1de90089).(); |
| 145 | _responsecxx . . $ QGtp#_response.=cxx . . $ QString#`operator=`(d02845eef0c33901)."Protocol version error"; |
| 146 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`!; |
| 147 | } |
| 148 | |
| 149 | busycxx . . $ QGtp#busy. = false; |
| 150 | return OKcxx . . $ `src/gtp/qgtp.h:25:9`!; |
| 151 | } |
| 152 | |
| 153 | // Read from stdout |
| 154 | void QGtpcxx . . $ QGtp#::slot_readFromStdoutcxx . . $ QGtp#slot_readFromStdout(49f6e7a06ebc5aa8).() |
| 155 | { |
| 156 | int number; |
| 157 | int pos; |
| 158 | |
| 159 | while (programProcesscxx . . $ QGtp#programProcess.->canReadLinecxx . . $ QProcess#canReadLine(50ce9a9e25b4a850).()) |
| 160 | { |
| 161 | answercxx . . $ QGtp#answer. =cxx . . $ QString#`operator=`(49ea8750b4987a17). programProcesscxx . . $ QGtp#programProcess.->readLinecxx . . $ QIODevice#readLine(1117a85f2fd4e5c8).(); |
| 162 | answercxx . . $ QGtp#answer..chopcxx . . $ QString#chop(d4f767463ce0a6b3).(1); // remove the trailing '\n' |
| 163 | responseReceivedcxx . . $ QGtp#responseReceived. = ((! answercxx . . $ QGtp#answer..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) && |
| 164 | ((answercxx . . $ QGtp#answer..atcxx . . $ QString#at(13af7ae5a875439e).(0) ==cxx . . $ `operator==`(a468b2f18a3afe8). '='cxx . . $ QChar#QChar(f349c77f591a7878).) || (answercxx . . $ QGtp#answer..atcxx . . $ QString#at(13af7ae5a875439e).(0) ==cxx . . $ `operator==`(a468b2f18a3afe8). '?'cxx . . $ QChar#QChar(f349c77f591a7878).))); |
| 165 | if (responseReceivedcxx . . $ QGtp#responseReceived.) |
| 166 | break; |
| 167 | } |
| 168 | if (!responseReceivedcxx . . $ QGtp#responseReceived.) |
| 169 | return; |
| 170 | |
| 171 | _responsecxx . . $ QGtp#_response. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). answercxx . . $ QGtp#answer.; |
| 172 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("** QGtp::slot_readFromStdout(): %s" , _responsecxx . . $ QGtp#_response..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 173 | |
| 174 | // do we have any answer after the command number ? |
| 175 | pos = _responsecxx . . $ QGtp#_response..indexOfcxx . . $ QString#indexOf(a1e52806cd31c200).(" "cxx . . $ QString#QString(85c52e162fed56f9).); |
| 176 | number = _responsecxx . . $ QGtp#_response..midcxx . . $ QString#mid(44b7563da18aea72).(1,pos).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 177 | |
| 178 | if (pos < 1) |
| 179 | _responsecxx . . $ QGtp#_response. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 180 | else |
| 181 | _responsecxx . . $ QGtp#_response. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). _responsecxx . . $ QGtp#_response..rightcxx . . $ QString#right(3f3c3d0e9c0eb37f).(_responsecxx . . $ QGtp#_response..lengthcxx . . $ QString#length(455f465bc33b4cdf).() - pos - 1); |
| 182 | |
| 183 | int i = moveRequestscxx . . $ QGtp#moveRequests..indexOfcxx . . $ QList#indexOf(fc79640c865a6596).(number); |
| 184 | if (i == -1) |
| 185 | return; |
| 186 | // Otherwise we have an answer to a move request. |
| 187 | // This is the one case in which we currently do not busy-wait. |
| 188 | busycxx . . $ QGtp#busy.=false; |
| 189 | moveRequestscxx . . $ QGtp#moveRequests..removeAtcxx . . $ QList#removeAt(d4f767463ce0a6b3).(i); |
| 190 | |
| 191 | if (_responsecxx . . $ QGtp#_response. ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "resign") |
| 192 | { |
| 193 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! computerResignedcxx . . $ QGtp#computerResigned(49f6e7a06ebc5aa8).(); |
| 194 | return; |
| 195 | } else if (_responsecxx . . $ QGtp#_response..containscxx . . $ QString#contains(8cce4688c16f48f3).("Pass"cxx . . $ QString#QString(85c52e162fed56f9).,Qtcxx . . $ Qt/::CaseInsensitivecxx . . $ Qt/CaseInsensitive.)) |
| 196 | { |
| 197 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! computerPassedcxx . . $ QGtp#computerPassed(49f6e7a06ebc5aa8).(); |
| 198 | return; |
| 199 | } |
| 200 | |
| 201 | int x = _responsecxx . . $ QGtp#_response.[cxx . . $ QString#`operator[]`(57436120916eb52c).0].unicodecxx . . $ QCharRef#unicode(39aa489f131cef24).() - QCharcxx . . $ QChar#::fromLatin1cxx . . $ QChar#fromLatin1(b9892872559b4892).('A').unicodecxx . . $ QChar#unicode(36716fbdc4fec2be).() + 1; |
| 202 | // skip 'J' |
| 203 | if (x > 8) |
| 204 | x--; |
| 205 | |
| 206 | int y; |
| 207 | if (_responsecxx . . $ QGtp#_response.[cxx . . $ QString#`operator[]`(57436120916eb52c).2] >=cxx . . $ `operator>=`(a468b2f18a3afe8). '0'cxx . . $ QChar#QChar(f349c77f591a7878). && _responsecxx . . $ QGtp#_response.[cxx . . $ QString#`operator[]`(57436120916eb52c).2] <=cxx . . $ `operator<=`(a468b2f18a3afe8). '9'cxx . . $ QChar#QChar(f349c77f591a7878).) |
| 208 | y = _responsecxx . . $ QGtp#_response..midcxx . . $ QString#mid(44b7563da18aea72).(1,2).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 209 | else |
| 210 | y = _responsecxx . . $ QGtp#_response.[cxx . . $ QString#`operator[]`(57436120916eb52c).1].digitValuecxx . . $ QCharRef#digitValue(455f465bc33b4cdf).(); |
| 211 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! signal_computerPlayedcxx . . $ QGtp#signal_computerPlayed(3e454b8ccf442868).( x, y ); |
| 212 | } |
| 213 | |
| 214 | // exit |
| 215 | void QGtpcxx . . $ QGtp#::slot_processExitedcxx . . $ QGtp#slot_processExited(15c350e1a5203cbf).(int exitCode, QProcesscxx . . $ QProcess#::ExitStatuscxx . . $ QProcess#ExitStatus# exitStatus) |
| 216 | { |
| 217 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Process Exited with exit code %i and status %d", exitCode, exitStatus); |
| 218 | // fflush ("quit"); |
| 219 | // return waitResponse(); |
| 220 | } |
| 221 | |
| 222 | /* Function: wait for a go response |
| 223 | * Arguments: none |
| 224 | * Fails: never |
| 225 | * Returns: nothing |
| 226 | */ |
| 227 | int |
| 228 | QGtpcxx . . $ QGtp#::waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).() |
| 229 | { |
| 230 | busycxx . . $ QGtp#busy.=true; |
| 231 | do //FIXME : use the readyRead signal of the process |
| 232 | { |
| 233 | programProcesscxx . . $ QGtp#programProcess.->waitForReadyReadcxx . . $ QProcess#waitForReadyRead(83c267b20bac841a).(10); |
| 234 | qAppcxx . . $ `<external>/6022697617041041825/qapplication.h:70:9`!->processEventscxx . . $ QCoreApplication#processEvents(5ce75b802d22674c).(); |
| 235 | } while (!responseReceivedcxx . . $ QGtp#responseReceived.); |
| 236 | |
| 237 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("** QGtp::waitResponse(): \'%s\'" , _responsecxx . . $ QGtp#_response..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 238 | responseReceivedcxx . . $ QGtp#responseReceived. = false; |
| 239 | busycxx . . $ QGtp#busy.=false; |
| 240 | |
| 241 | return ((answercxx . . $ QGtp#answer..atcxx . . $ QString#at(13af7ae5a875439e).(0) ==cxx . . $ `operator==`(a468b2f18a3afe8). '='cxx . . $ QChar#QChar(f349c77f591a7878).) ? OKcxx . . $ `src/gtp/qgtp.h:25:9`! : FAILcxx . . $ `src/gtp/qgtp.h:26:9`! ); |
| 242 | } |
| 243 | |
| 244 | /**************************** |
| 245 | * Program identity. * |
| 246 | ****************************/ |
| 247 | |
| 248 | /* Function: Report the name of the program. |
| 249 | * Arguments: none |
| 250 | * Fails: never |
| 251 | * Returns: program name |
| 252 | */ |
| 253 | int |
| 254 | QGtpcxx . . $ QGtp#::namecxx . . $ QGtp#name(b126dc7c1de90089). () |
| 255 | { |
| 256 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("name"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 257 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 258 | } |
| 259 | |
| 260 | /* Function: Report protocol version. |
| 261 | * Arguments: none |
| 262 | * Fails: never |
| 263 | * Returns: protocol version number |
| 264 | */ |
| 265 | int |
| 266 | QGtpcxx . . $ QGtp#::protocolVersioncxx . . $ QGtp#protocolVersion(b126dc7c1de90089). () |
| 267 | { |
| 268 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("protocol_version"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 269 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 270 | } |
| 271 | |
| 272 | void QGtpcxx . . $ QGtp#::fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray# s) |
| 273 | { |
| 274 | if (issueCmdNbcxx . . $ QGtp#issueCmdNb.) |
| 275 | { |
| 276 | s =cxx . . $ QByteArray#`operator=`(acee8257ca81216f). QStringcxx . . $ QString#QString(ced63f7c635d850d).().setNumcxx . . $ QString#setNum(6483560ce2afa901).(_cptcxx . . $ QGtp#_cpt.++).toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).() +cxx . . $ operator+(8f17b704cda0d21f). " " +cxx . . $ operator+(49e2485dc0bda598). s; |
| 277 | } |
| 278 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("flush -> %s",s.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 279 | s +=cxx . . $ QByteArray#`operator+=`(1815c0e4073627df). '\n'; |
| 280 | int i= programProcesscxx . . $ QGtp#programProcess.->writecxx . . $ QIODevice#write(4ee2750a0be83987).(s); |
| 281 | |
| 282 | if ( i != s.sizecxx . . $ QByteArray#size(455f465bc33b4cdf).()) |
| 283 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Error writing %s",s.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 284 | } |
| 285 | |
| 286 | /**************************** |
| 287 | * Administrative commands. * |
| 288 | ****************************/ |
| 289 | |
| 290 | /* Function: Quit |
| 291 | * Arguments: none |
| 292 | * Fails: never |
| 293 | * Returns: nothing |
| 294 | */ |
| 295 | int |
| 296 | QGtpcxx . . $ QGtp#::quitcxx . . $ QGtp#quit(b126dc7c1de90089). () |
| 297 | { |
| 298 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("quit"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 299 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 300 | } |
| 301 | |
| 302 | /* Function: Report the version number of the program. |
| 303 | * Arguments: none |
| 304 | * Fails: never |
| 305 | * Returns: version number |
| 306 | */ |
| 307 | int |
| 308 | QGtpcxx . . $ QGtp#::versioncxx . . $ QGtp#version(b126dc7c1de90089). () |
| 309 | { |
| 310 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("version"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 311 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | /*************************** |
| 316 | * Setting the board size. * |
| 317 | ***************************/ |
| 318 | |
| 319 | /* Function: Set the board size to NxN. |
| 320 | * Arguments: integer |
| 321 | * Fails: board size outside engine's limits |
| 322 | * Returns: nothing |
| 323 | */ |
| 324 | int |
| 325 | QGtpcxx . . $ QGtp#::setBoardsizecxx . . $ QGtp#setBoardsize(7864480464b09eea). (int size) |
| 326 | { |
| 327 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("boardsize "+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(size)); |
| 328 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 329 | } |
| 330 | |
| 331 | |
| 332 | /* Function: Find the current boardsize |
| 333 | * Arguments: none |
| 334 | * Fails: never |
| 335 | * Returns: board_size |
| 336 | */ |
| 337 | int |
| 338 | QGtpcxx . . $ QGtp#::queryBoardsizecxx . . $ QGtp#queryBoardsize(b126dc7c1de90089).() |
| 339 | { |
| 340 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("query_boardsize"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 341 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 342 | } |
| 343 | |
| 344 | /*********************** |
| 345 | * Clearing the board. * |
| 346 | ***********************/ |
| 347 | |
| 348 | /* Function: Clear the board. |
| 349 | * Arguments: none |
| 350 | * Fails: never |
| 351 | * Returns: nothing |
| 352 | */ |
| 353 | |
| 354 | int |
| 355 | QGtpcxx . . $ QGtp#::clearBoardcxx . . $ QGtp#clearBoard(b126dc7c1de90089). () |
| 356 | { |
| 357 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("clear_board"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 358 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 359 | } |
| 360 | |
| 361 | /*************************** |
| 362 | * Setting. * |
| 363 | ***************************/ |
| 364 | |
| 365 | /* Function: Set the komi. |
| 366 | * Arguments: float |
| 367 | * Fails: incorrect argument |
| 368 | * Returns: nothing |
| 369 | */ |
| 370 | int |
| 371 | QGtpcxx . . $ QGtp#::setKomicxx . . $ QGtp#setKomi(1bb0578f3efdc255).(float f) |
| 372 | { |
| 373 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QStringcxx . . $ QString#QString(85c52e162fed56f9).("komi %1").argcxx . . $ QString#arg(37c95ac69556aa00).(f,0,'f',2).toLatin1cxx . . $ QString#toLatin1(7c2073558a834e49).()); |
| 374 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 375 | } |
| 376 | |
| 377 | /* Function: Set the playing level. |
| 378 | * Arguments: int |
| 379 | * Fails: incorrect argument |
| 380 | * Returns: nothing |
| 381 | */ |
| 382 | int |
| 383 | QGtpcxx . . $ QGtp#::setLevelcxx . . $ QGtp#setLevel(7864480464b09eea). (int level) |
| 384 | { |
| 385 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("level "+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(level)); |
| 386 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 387 | } |
| 388 | /****************** |
| 389 | * Playing moves. * |
| 390 | ******************/ |
| 391 | |
| 392 | /* Function: Play a black stone at the given vertex. |
| 393 | * Arguments: vertex |
| 394 | * Fails: invalid vertex, illegal move |
| 395 | * Returns: nothing |
| 396 | */ |
| 397 | int |
| 398 | QGtpcxx . . $ QGtp#::playblackcxx . . $ QGtp#playblack(9b79fb6aee4c0440). (int x, int y) |
| 399 | { |
| 400 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("play black ")+cxx . . $ operator+(49e2485dc0bda598).encodeCoorscxx . . $ QGtp#encodeCoors(4869bc8897d11479).(x,y)); |
| 401 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 402 | } |
| 403 | |
| 404 | /* Function: Black pass. |
| 405 | * Arguments: None |
| 406 | * Fails: never |
| 407 | * Returns: nothing |
| 408 | */ |
| 409 | int |
| 410 | QGtpcxx . . $ QGtp#::playblackPasscxx . . $ QGtp#playblackPass(b126dc7c1de90089). () |
| 411 | { |
| 412 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("play black pass"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 413 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 414 | } |
| 415 | |
| 416 | /* Function: Play a white stone at the given vertex. |
| 417 | * Arguments: vertex |
| 418 | * Fails: invalid vertex, illegal move |
| 419 | * Returns: nothing |
| 420 | */ |
| 421 | int |
| 422 | QGtpcxx . . $ QGtp#::playwhitecxx . . $ QGtp#playwhite(9b79fb6aee4c0440). (int x, int y) |
| 423 | { |
| 424 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("play white "+cxx . . $ operator+(c76e440e68d4afec).encodeCoorscxx . . $ QGtp#encodeCoors(4869bc8897d11479).(x,y)); |
| 425 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 426 | } |
| 427 | |
| 428 | /* Function: White pass. |
| 429 | * Arguments: none |
| 430 | * Fails: never |
| 431 | * Returns: nothing |
| 432 | */ |
| 433 | int |
| 434 | QGtpcxx . . $ QGtp#::playwhitePasscxx . . $ QGtp#playwhitePass(b126dc7c1de90089). () |
| 435 | { |
| 436 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("play white pass"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 437 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 438 | } |
| 439 | |
| 440 | /* Function: Set up fixed placement handicap stones. |
| 441 | * Arguments: number of handicap stones |
| 442 | * Fails: invalid number of stones for the current boardsize |
| 443 | * Returns: list of vertices with handicap stones |
| 444 | */ |
| 445 | int |
| 446 | QGtpcxx . . $ QGtp#::fixedHandicapcxx . . $ QGtp#fixedHandicap(7864480464b09eea). (int handicap) |
| 447 | { |
| 448 | if (handicap < 2) |
| 449 | return OKcxx . . $ `src/gtp/qgtp.h:25:9`!; |
| 450 | |
| 451 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("fixed_handicap "+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(handicap)); |
| 452 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 453 | } |
| 454 | |
| 455 | int QGtpcxx . . $ QGtp#::set_free_handicapcxx . . $ QGtp#set_free_handicap(c73e7c52a16cf11a).(QListcxx . . $ QList#<Pointcxx . . $ Point#> handicap_stones) |
| 456 | { |
| 457 | QByteArraycxx . . $ QByteArray# messagecxx . . $ QByteArray#QByteArray(34d26762b42c433a).("set_free_handicap"); |
| 458 | for ( int i=0; i<handicap_stones.lengthcxx . . $ QList#length(455f465bc33b4cdf).(); ++i ) |
| 459 | { |
| 460 | message.appendcxx . . $ QByteArray#append(715145f812399bcb).(" ").appendcxx . . $ QByteArray#append(85c7caed82076bbb).(encodeCoorscxx . . $ QGtp#encodeCoors(4869bc8897d11479).(handicap_stones[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i].xcxx . . $ Point#x.,handicap_stones[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i].ycxx . . $ Point#y.)); |
| 461 | } |
| 462 | |
| 463 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (messagecxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).); |
| 464 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 465 | } |
| 466 | |
| 467 | /* Function: Load an sgf file, possibly up to a move number or the first |
| 468 | * occurence of a move. |
| 469 | * Arguments: filename + move number, vertex, or nothing |
| 470 | * Fails: missing filename or failure to open or parse file |
| 471 | * Returns: color to play |
| 472 | */ |
| 473 | int QGtpcxx . . $ QGtp#::loadsgfcxx . . $ QGtp#loadsgf(ee4ca58270b3874e). (QStringcxx . . $ QString# filename,int /*movNumber*/,char /*c*/,int /*i*/) |
| 474 | { |
| 475 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QStringcxx . . $ QString#QString(85c52e162fed56f9).("loadsgf %1").argcxx . . $ QString#arg(bc823072288cbbb5).(filename).toLatin1cxx . . $ QString#toLatin1(7c2073558a834e49).()); |
| 476 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 477 | } |
| 478 | |
| 479 | /***************** |
| 480 | * Board status. * |
| 481 | *****************/ |
| 482 | |
| 483 | /* Function: Return the color at a vertex. |
| 484 | * Arguments: vertex |
| 485 | * Fails: invalid vertex |
| 486 | * Returns: "black", "white", or "empty" |
| 487 | */ |
| 488 | int |
| 489 | QGtpcxx . . $ QGtp#::whatColorcxx . . $ QGtp#whatColor(f47ee98913c22bd1). (char c, int i) |
| 490 | { |
| 491 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("color "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 492 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 493 | } |
| 494 | |
| 495 | /* Function: Count number of liberties for the string at a vertex. |
| 496 | * Arguments: vertex |
| 497 | * Fails: invalid vertex, empty vertex |
| 498 | * Returns: Number of liberties. |
| 499 | */ |
| 500 | int |
| 501 | QGtpcxx . . $ QGtp#::countlibcxx . . $ QGtp#countlib(f47ee98913c22bd1). (char c, int i) |
| 502 | { |
| 503 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("countlib "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 504 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 505 | } |
| 506 | |
| 507 | /* Function: Return the positions of the liberties for the string at a vertex. |
| 508 | * Arguments: vertex |
| 509 | * Fails: invalid vertex, empty vertex |
| 510 | * Returns: Sorted space separated list of vertices. |
| 511 | */ |
| 512 | int |
| 513 | QGtpcxx . . $ QGtp#::findlibcxx . . $ QGtp#findlib(f47ee98913c22bd1). (char c, int i) |
| 514 | { |
| 515 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("findlib "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 516 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 517 | } |
| 518 | |
| 519 | /* Function: Tell whether a move is legal. |
| 520 | * Arguments: move |
| 521 | * Fails: invalid move |
| 522 | * Returns: 1 if the move is legal, 0 if it is not. |
| 523 | */ |
| 524 | int |
| 525 | QGtpcxx . . $ QGtp#::isLegalcxx . . $ QGtp#isLegal(2de9b7c1be362fba). (QStringcxx . . $ QString# color, char c, int i) |
| 526 | { |
| 527 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QStringcxx . . $ QString#QString(85c52e162fed56f9).("is_legal %1 ").argcxx . . $ QString#arg(bc823072288cbbb5).(color).toLatin1cxx . . $ QString#toLatin1(7c2073558a834e49).()+cxx . . $ operator+(3dec5636b72f978c).c+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 528 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 529 | } |
| 530 | |
| 531 | /* Function: List all legal moves for either color. |
| 532 | * Arguments: color |
| 533 | * Fails: invalid color |
| 534 | * Returns: Sorted space separated list of vertices. |
| 535 | */ |
| 536 | int |
| 537 | QGtpcxx . . $ QGtp#::allLegalcxx . . $ QGtp#allLegal(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# color) |
| 538 | { |
| 539 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("all_legal ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 540 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 541 | } |
| 542 | |
| 543 | /* Function: List the number of captures taken by either color. |
| 544 | * Arguments: color |
| 545 | * Fails: invalid color |
| 546 | * Returns: Number of captures. |
| 547 | */ |
| 548 | int |
| 549 | QGtpcxx . . $ QGtp#::capturescxx . . $ QGtp#captures(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# color) |
| 550 | { |
| 551 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("captures")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 552 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 553 | } |
| 554 | |
| 555 | /********************** |
| 556 | * Retractable moves. * |
| 557 | **********************/ |
| 558 | |
| 559 | /* Function: Play a stone of the given color at the given vertex. |
| 560 | * Arguments: move (color + vertex) |
| 561 | * Fails: invalid color, invalid vertex, illegal move |
| 562 | * Returns: nothing |
| 563 | */ |
| 564 | int |
| 565 | QGtpcxx . . $ QGtp#::trymovecxx . . $ QGtp#trymove(2de9b7c1be362fba). (QStringcxx . . $ QString# color, char c, int i) |
| 566 | { |
| 567 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). (QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("trymove ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(3dec5636b72f978c).c+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 568 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 569 | } |
| 570 | |
| 571 | /* Function: Undo a trymove. |
| 572 | * Arguments: none |
| 573 | * Fails: stack empty |
| 574 | * Returns: nothing |
| 575 | */ |
| 576 | int |
| 577 | QGtpcxx . . $ QGtp#::popgocxx . . $ QGtp#popgo(b126dc7c1de90089). () |
| 578 | { |
| 579 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("popgo"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 580 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 581 | } |
| 582 | |
| 583 | /********************* |
| 584 | * Tactical reading. * |
| 585 | *********************/ |
| 586 | |
| 587 | /* Function: Try to attack a string. |
| 588 | * Arguments: vertex |
| 589 | * Fails: invalid vertex, empty vertex |
| 590 | * Returns: attack code followed by attack point if attack code nonzero. |
| 591 | */ |
| 592 | int |
| 593 | QGtpcxx . . $ QGtp#::attackcxx . . $ QGtp#attack(f47ee98913c22bd1). (char c, int i) |
| 594 | { |
| 595 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("attack "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 596 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 597 | } |
| 598 | |
| 599 | /* Function: Try to defend a string. |
| 600 | * Arguments: vertex |
| 601 | * Fails: invalid vertex, empty vertex |
| 602 | * Returns: defense code followed by defense point if defense code nonzero. |
| 603 | */ |
| 604 | int |
| 605 | QGtpcxx . . $ QGtp#::defendcxx . . $ QGtp#defend(f47ee98913c22bd1). (char c, int i) |
| 606 | { |
| 607 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b). ("defend "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 608 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 609 | } |
| 610 | |
| 611 | /* Function: Increase depth values by one. |
| 612 | * Arguments: none |
| 613 | * Fails: never |
| 614 | * Returns: nothing |
| 615 | */ |
| 616 | int |
| 617 | QGtpcxx . . $ QGtp#::increaseDepthscxx . . $ QGtp#increaseDepths(b126dc7c1de90089). () |
| 618 | { |
| 619 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("increase_depths"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 620 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 621 | } |
| 622 | |
| 623 | /* Function: Decrease depth values by one. |
| 624 | * Arguments: none |
| 625 | * Fails: never |
| 626 | * Returns: nothing |
| 627 | */ |
| 628 | int |
| 629 | QGtpcxx . . $ QGtp#::decreaseDepthscxx . . $ QGtp#decreaseDepths(b126dc7c1de90089). () |
| 630 | { |
| 631 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("decrease_depths"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 632 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 633 | } |
| 634 | |
| 635 | /****************** |
| 636 | * owl reading. * |
| 637 | ******************/ |
| 638 | |
| 639 | /* Function: Try to attack a dragon. |
| 640 | * Arguments: vertex |
| 641 | * Fails: invalid vertex, empty vertex |
| 642 | * Returns: attack code followed by attack point if attack code nonzero. |
| 643 | */ |
| 644 | int |
| 645 | QGtpcxx . . $ QGtp#::owlAttackcxx . . $ QGtp#owlAttack(f47ee98913c22bd1). (char c, int i) |
| 646 | { |
| 647 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("owl_attack "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 648 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 649 | } |
| 650 | |
| 651 | /* Function: Try to defend a dragon. |
| 652 | * Arguments: vertex |
| 653 | * Fails: invalid vertex, empty vertex |
| 654 | * Returns: defense code followed by defense point if defense code nonzero. |
| 655 | */ |
| 656 | int |
| 657 | QGtpcxx . . $ QGtp#::owlDefendcxx . . $ QGtp#owlDefend(f47ee98913c22bd1). (char c, int i) |
| 658 | { |
| 659 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("owl_defend "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 660 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 661 | } |
| 662 | |
| 663 | /******** |
| 664 | * eyes * |
| 665 | ********/ |
| 666 | |
| 667 | /* Function: Evaluate an eye space |
| 668 | * Arguments: vertex |
| 669 | * Fails: invalid vertex |
| 670 | * Returns: Minimum and maximum number of eyes. If these differ an |
| 671 | * attack and a defense point are additionally returned. |
| 672 | * If the vertex is not an eye space or not of unique color, |
| 673 | * a single -1 is returned. |
| 674 | */ |
| 675 | |
| 676 | int |
| 677 | QGtpcxx . . $ QGtp#::evalEyecxx . . $ QGtp#evalEye(f47ee98913c22bd1). (char c, int i) |
| 678 | { |
| 679 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("eval_eye "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 680 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 681 | } |
| 682 | |
| 683 | /***************** |
| 684 | * dragon status * |
| 685 | *****************/ |
| 686 | |
| 687 | /* Function: Determine status of a dragon. |
| 688 | * Arguments: vertex |
| 689 | * Fails: invalid vertex, empty vertex |
| 690 | * Returns: status ("alive", "critical", "dead", or "unknown"), |
| 691 | * attack point, defense point. Points of attack and |
| 692 | * defense are only given if the status is critical and the |
| 693 | * owl code is enabled. |
| 694 | * |
| 695 | * FIXME: Should be able to distinguish between life in seki |
| 696 | * and life with territory. Should also be able to identify ko. |
| 697 | */ |
| 698 | |
| 699 | int |
| 700 | QGtpcxx . . $ QGtp#::dragonStatuscxx . . $ QGtp#dragonStatus(f47ee98913c22bd1). (char c, int i) |
| 701 | { |
| 702 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("dragon_status %1%2").argcxx . . $ QString#arg(41095343a58afb70).(c).argcxx . . $ QString#arg(64ab2ed17cc11715).(i).toLatin1cxx . . $ QString#toLatin1(7c2073558a834e49).()); |
| 703 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 704 | } |
| 705 | |
| 706 | /* Function: Determine whether two stones belong to the same dragon. |
| 707 | * Arguments: vertex, vertex |
| 708 | * Fails: invalid vertex, empty vertex |
| 709 | * Returns: 1 if the vertices belong to the same dragon, 0 otherwise |
| 710 | */ |
| 711 | |
| 712 | int |
| 713 | QGtpcxx . . $ QGtp#::sameDragoncxx . . $ QGtp#sameDragon(24f15965b831f2f8). (char c1, int i1, char c2, int i2) |
| 714 | { |
| 715 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("same_dragon %1%2 %3%4").argcxx . . $ QString#arg(41095343a58afb70).(c1).argcxx . . $ QString#arg(64ab2ed17cc11715).(i1).argcxx . . $ QString#arg(41095343a58afb70).(c2).argcxx . . $ QString#arg(64ab2ed17cc11715).(i2).toLatin1cxx . . $ QString#toLatin1(7c2073558a834e49).()); |
| 716 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 717 | } |
| 718 | |
| 719 | /* Function: Return the information in the dragon data structure. |
| 720 | * Arguments: nothing |
| 721 | * Fails: never |
| 722 | * Returns: Dragon data formatted in the corresponding way to gtp_worm__ |
| 723 | */ |
| 724 | int |
| 725 | QGtpcxx . . $ QGtp#::dragonDatacxx . . $ QGtp#dragonData(b126dc7c1de90089). () |
| 726 | { |
| 727 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("dragon_data"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 728 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 729 | } |
| 730 | |
| 731 | /* Function: Return the information in the dragon data structure. |
| 732 | * Arguments: intersection |
| 733 | * Fails: invalid coordinate |
| 734 | * Returns: Dragon data formatted in the corresponding way to gtp_worm__ |
| 735 | */ |
| 736 | int |
| 737 | QGtpcxx . . $ QGtp#::dragonDatacxx . . $ QGtp#dragonData(f47ee98913c22bd1). (char c,int i) |
| 738 | { |
| 739 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("dragon_data "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 740 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 741 | } |
| 742 | |
| 743 | /*********************** |
| 744 | * combination attacks * |
| 745 | ***********************/ |
| 746 | |
| 747 | /* Function: Find a move by color capturing something through a |
| 748 | * combination attack. |
| 749 | * Arguments: color |
| 750 | * Fails: invalid color |
| 751 | * Returns: Recommended move, PASS if no move found |
| 752 | */ |
| 753 | |
| 754 | int |
| 755 | QGtpcxx . . $ QGtp#::combinationAttackcxx . . $ QGtp#combinationAttack(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# color) |
| 756 | { |
| 757 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("combination_attack ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 758 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 759 | } |
| 760 | |
| 761 | /******************** |
| 762 | * generating moves * |
| 763 | ********************/ |
| 764 | |
| 765 | /* Function: Generate and play the supposedly best black move. |
| 766 | * Arguments: none |
| 767 | * Fails: never |
| 768 | * Returns: a move coordinate (or "PASS") |
| 769 | */ |
| 770 | int |
| 771 | QGtpcxx . . $ QGtp#::genmoveBlackcxx . . $ QGtp#genmoveBlack(b126dc7c1de90089). () |
| 772 | { |
| 773 | if (busycxx . . $ QGtp#busy.) |
| 774 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`!; // Ignore multiple requests while the engine is busy |
| 775 | |
| 776 | moveRequestscxx . . $ QGtp#moveRequests..appendcxx . . $ QList#append(77d9f17553126ecb).(_cptcxx . . $ QGtp#_cpt.); |
| 777 | busycxx . . $ QGtp#busy.=true; |
| 778 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("genmove black"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 779 | return OKcxx . . $ `src/gtp/qgtp.h:25:9`!; |
| 780 | } |
| 781 | |
| 782 | /* Function: Generate and play the supposedly best white move. |
| 783 | * Arguments: none |
| 784 | * Fails: never |
| 785 | * Returns: a move coordinate (or "PASS") |
| 786 | */ |
| 787 | int |
| 788 | QGtpcxx . . $ QGtp#::genmoveWhitecxx . . $ QGtp#genmoveWhite(b126dc7c1de90089). () |
| 789 | { |
| 790 | if (busycxx . . $ QGtp#busy.) |
| 791 | return FAILcxx . . $ `src/gtp/qgtp.h:26:9`!; |
| 792 | |
| 793 | moveRequestscxx . . $ QGtp#moveRequests..appendcxx . . $ QList#append(77d9f17553126ecb).(_cptcxx . . $ QGtp#_cpt.); |
| 794 | busycxx . . $ QGtp#busy.=true; |
| 795 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("genmove white"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 796 | return OKcxx . . $ `src/gtp/qgtp.h:25:9`!; |
| 797 | } |
| 798 | |
| 799 | /* Function: Generate the supposedly best move for either color. |
| 800 | * Arguments: color to move, optionally a random seed |
| 801 | * Fails: invalid color |
| 802 | * Returns: a move coordinate (or "PASS") |
| 803 | */ |
| 804 | int |
| 805 | QGtpcxx . . $ QGtp#::genmovecxx . . $ QGtp#genmove(60e26aecde23a425). (QStringcxx . . $ QString# color,int seed) |
| 806 | { |
| 807 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("gg_genmove ") +cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(seed)); |
| 808 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 809 | } |
| 810 | |
| 811 | /* Function : Generate a list of the best moves for White with weights |
| 812 | * Arguments: none |
| 813 | * Fails: : never |
| 814 | * Returns : list of moves with weights |
| 815 | */ |
| 816 | |
| 817 | int |
| 818 | QGtpcxx . . $ QGtp#::topMovesWhitecxx . . $ QGtp#topMovesWhite(b126dc7c1de90089). () |
| 819 | { |
| 820 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("top_moves_white"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 821 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 822 | } |
| 823 | |
| 824 | /* Function : Generate a list of the best moves for Black with weights |
| 825 | * Arguments: none |
| 826 | * Fails: : never |
| 827 | * Returns : list of moves with weights |
| 828 | */ |
| 829 | |
| 830 | int |
| 831 | QGtpcxx . . $ QGtp#::topMovesBlackcxx . . $ QGtp#topMovesBlack(b126dc7c1de90089). () |
| 832 | { |
| 833 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("top_moves_black"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 834 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 835 | } |
| 836 | |
| 837 | /* Function: Undo last move |
| 838 | * Arguments: int |
| 839 | * Fails: If move pointer is 0 |
| 840 | * Returns: nothing |
| 841 | */ |
| 842 | int |
| 843 | QGtpcxx . . $ QGtp#::undocxx . . $ QGtp#undo(7864480464b09eea). (int i) |
| 844 | { |
| 845 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("undo "+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 846 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 847 | } |
| 848 | |
| 849 | /* Function: Report the final status of a vertex in a finished game. |
| 850 | * Arguments: Vertex, optional random seed |
| 851 | * Fails: invalid vertex |
| 852 | * Returns: Status in the form of one of the strings "alive", "dead", |
| 853 | * "seki", "white_territory", "black_territory", or "dame". |
| 854 | */ |
| 855 | int |
| 856 | QGtpcxx . . $ QGtp#::finalStatuscxx . . $ QGtp#finalStatus(9e9bcf41842a210f). (char c, int i, int seed) |
| 857 | { |
| 858 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("final_status "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(seed)); |
| 859 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 860 | } |
| 861 | |
| 862 | /* Function: Report vertices with a specific final status in a finished game. |
| 863 | * Arguments: Status in the form of one of the strings "alive", "dead", |
| 864 | * "seki", "white_territory", "black_territory", or "dame". |
| 865 | * An optional random seed can be added. |
| 866 | * Fails: missing or invalid status string |
| 867 | * Returns: Vertices having the specified status. These are split with |
| 868 | * one string on each line if the vertices are nonempty (i.e. |
| 869 | * for "alive", "dead", and "seki"). |
| 870 | */ |
| 871 | int |
| 872 | QGtpcxx . . $ QGtp#::finalStatusListcxx . . $ QGtp#finalStatusList(60e26aecde23a425). (QStringcxx . . $ QString# status, int seed) |
| 873 | { |
| 874 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("final_status_list ")+cxx . . $ operator+(49e2485dc0bda598).status.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(seed)); |
| 875 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 876 | } |
| 877 | |
| 878 | /************** |
| 879 | * score * |
| 880 | **************/ |
| 881 | |
| 882 | /* Function: Compute the score of a finished game. |
| 883 | * Arguments: Optional random seed |
| 884 | * Fails: never |
| 885 | * Returns: Score in SGF format (RE property). |
| 886 | */ |
| 887 | int |
| 888 | QGtpcxx . . $ QGtp#::finalScorecxx . . $ QGtp#finalScore(7864480464b09eea). (int seed) |
| 889 | { |
| 890 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("final_score "+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(seed)); |
| 891 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 892 | } |
| 893 | |
| 894 | int |
| 895 | QGtpcxx . . $ QGtp#::estimateScorecxx . . $ QGtp#estimateScore(b126dc7c1de90089). () |
| 896 | { |
| 897 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("estimate_score"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 898 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 899 | } |
| 900 | |
| 901 | int |
| 902 | QGtpcxx . . $ QGtp#::newScorecxx . . $ QGtp#newScore(b126dc7c1de90089). () |
| 903 | { |
| 904 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("new_score"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 905 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 906 | } |
| 907 | |
| 908 | /************** |
| 909 | * statistics * |
| 910 | **************/ |
| 911 | |
| 912 | /* Function: Reset the count of life nodes. |
| 913 | * Arguments: none |
| 914 | * Fails: never |
| 915 | * Returns: nothing |
| 916 | */ |
| 917 | int |
| 918 | QGtpcxx . . $ QGtp#::resetLifeNodeCountercxx . . $ QGtp#resetLifeNodeCounter(b126dc7c1de90089). () |
| 919 | { |
| 920 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("reset_life_node_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 921 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 922 | } |
| 923 | |
| 924 | /* Function: Retrieve the count of life nodes. |
| 925 | * Arguments: none |
| 926 | * Fails: never |
| 927 | * Returns: number of life nodes |
| 928 | */ |
| 929 | int |
| 930 | QGtpcxx . . $ QGtp#::getLifeNodeCountercxx . . $ QGtp#getLifeNodeCounter(b126dc7c1de90089). () |
| 931 | { |
| 932 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("get_life_node_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 933 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 934 | } |
| 935 | |
| 936 | /* Function: Reset the count of owl nodes. |
| 937 | * Arguments: none |
| 938 | * Fails: never |
| 939 | * Returns: nothing |
| 940 | */ |
| 941 | int |
| 942 | QGtpcxx . . $ QGtp#::resetOwlNodeCountercxx . . $ QGtp#resetOwlNodeCounter(b126dc7c1de90089). () |
| 943 | { |
| 944 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("reset_owl_node_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 945 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 946 | } |
| 947 | |
| 948 | /* Function: Retrieve the count of owl nodes. |
| 949 | * Arguments: none |
| 950 | * Fails: never |
| 951 | * Returns: number of owl nodes |
| 952 | */ |
| 953 | int |
| 954 | QGtpcxx . . $ QGtp#::getOwlNodeCountercxx . . $ QGtp#getOwlNodeCounter(b126dc7c1de90089). () |
| 955 | { |
| 956 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("get_owl_node_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 957 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 958 | } |
| 959 | |
| 960 | /* Function: Reset the count of reading nodes. |
| 961 | * Arguments: none |
| 962 | * Fails: never |
| 963 | * Returns: nothing |
| 964 | */ |
| 965 | int |
| 966 | QGtpcxx . . $ QGtp#::resetReadingNodeCountercxx . . $ QGtp#resetReadingNodeCounter(b126dc7c1de90089). () |
| 967 | { |
| 968 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("reset_reading_node_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 969 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 970 | } |
| 971 | |
| 972 | /* Function: Retrieve the count of reading nodes. |
| 973 | * Arguments: none |
| 974 | * Fails: never |
| 975 | * Returns: number of reading nodes |
| 976 | */ |
| 977 | int |
| 978 | QGtpcxx . . $ QGtp#::getReadingNodeCountercxx . . $ QGtp#getReadingNodeCounter(b126dc7c1de90089). () |
| 979 | { |
| 980 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("get_reading_node_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 981 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 982 | } |
| 983 | |
| 984 | /* Function: Reset the count of trymoves/trykos. |
| 985 | * Arguments: none |
| 986 | * Fails: never |
| 987 | * Returns: nothing |
| 988 | */ |
| 989 | int |
| 990 | QGtpcxx . . $ QGtp#::resetTrymoveCountercxx . . $ QGtp#resetTrymoveCounter(b126dc7c1de90089). () |
| 991 | { |
| 992 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("reset_trymove_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 993 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 994 | } |
| 995 | |
| 996 | /* Function: Retrieve the count of trymoves/trykos. |
| 997 | * Arguments: none |
| 998 | * Fails: never |
| 999 | * Returns: number of trymoves/trykos |
| 1000 | */ |
| 1001 | int |
| 1002 | QGtpcxx . . $ QGtp#::getTrymoveCountercxx . . $ QGtp#getTrymoveCounter(b126dc7c1de90089). () |
| 1003 | { |
| 1004 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("get_trymove_counter"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 1005 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1006 | } |
| 1007 | |
| 1008 | /********* |
| 1009 | * debug * |
| 1010 | *********/ |
| 1011 | |
| 1012 | /* Function: Write the position to stderr. |
| 1013 | * Arguments: none |
| 1014 | * Fails: never |
| 1015 | * Returns: nothing |
| 1016 | */ |
| 1017 | int |
| 1018 | QGtpcxx . . $ QGtp#::showboardcxx . . $ QGtp#showboard(b126dc7c1de90089). () |
| 1019 | { |
| 1020 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("showboard"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 1021 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1022 | } |
| 1023 | |
| 1024 | /* Function: Dump stack to stderr. |
| 1025 | * Arguments: none |
| 1026 | * Fails: never |
| 1027 | * Returns: nothing |
| 1028 | */ |
| 1029 | int |
| 1030 | QGtpcxx . . $ QGtp#::dumpStackcxx . . $ QGtp#dumpStack(b126dc7c1de90089). () |
| 1031 | { |
| 1032 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("dump_stack"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 1033 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1034 | } |
| 1035 | |
| 1036 | /* Function: Write information about the influence function to stderr. |
| 1037 | * Arguments: color to move, optionally a list of what to show |
| 1038 | * Fails: invalid color |
| 1039 | * Returns: nothing |
| 1040 | */ |
| 1041 | int |
| 1042 | QGtpcxx . . $ QGtp#::debugInfluencecxx . . $ QGtp#debugInfluence(cf8c7f074bbf9512). (QStringcxx . . $ QString# color,QStringcxx . . $ QString# list) |
| 1043 | { |
| 1044 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("debug_influence ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(49e2485dc0bda598).list.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1045 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1046 | } |
| 1047 | |
| 1048 | /* Function: Write information about the influence function after making |
| 1049 | * a move to stderr. |
| 1050 | * Arguments: move, optionally a list of what to show |
| 1051 | * Fails: never |
| 1052 | * Returns: nothing |
| 1053 | */ |
| 1054 | int |
| 1055 | QGtpcxx . . $ QGtp#::debugMoveInfluencecxx . . $ QGtp#debugMoveInfluence(d6dcd0014ed33d8b). (QStringcxx . . $ QString# color, char c, int i,QStringcxx . . $ QString# list) |
| 1056 | { |
| 1057 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("debug_move_influence ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()+cxx . . $ operator+(8f17b704cda0d21f). |
| 1058 | " "+cxx . . $ operator+(3dec5636b72f978c).c+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(49e2485dc0bda598).list.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1059 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1060 | } |
| 1061 | |
| 1062 | /* Function: Return information about the influence function. |
| 1063 | * Arguments: color to move |
| 1064 | * Fails: never |
| 1065 | * Returns: Influence data formatted |
| 1066 | */ |
| 1067 | int |
| 1068 | QGtpcxx . . $ QGtp#::influencecxx . . $ QGtp#influence(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# color) |
| 1069 | { |
| 1070 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("influence ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1071 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1072 | } |
| 1073 | |
| 1074 | /* Function: Return information about the influence function after a move |
| 1075 | * Arguments: move |
| 1076 | * Fails: never |
| 1077 | * Returns: Influence data formatted in the same way as for gtp_influence. |
| 1078 | */ |
| 1079 | int |
| 1080 | QGtpcxx . . $ QGtp#::moveInfluencecxx . . $ QGtp#moveInfluence(2de9b7c1be362fba). (QStringcxx . . $ QString# color, char c, int i) |
| 1081 | { |
| 1082 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("move_influence ")+cxx . . $ operator+(49e2485dc0bda598).color.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()+cxx . . $ operator+(8f17b704cda0d21f)." "+cxx . . $ operator+(3dec5636b72f978c).c+cxx . . $ operator+(49e2485dc0bda598).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 1083 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1084 | } |
| 1085 | |
| 1086 | /* Function: Return the information in the worm data structure. |
| 1087 | * Arguments: none |
| 1088 | * Fails: never |
| 1089 | * Returns: Worm data formatted |
| 1090 | */ |
| 1091 | int |
| 1092 | QGtpcxx . . $ QGtp#::wormDatacxx . . $ QGtp#wormData(b126dc7c1de90089). () |
| 1093 | { |
| 1094 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("worm_data"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 1095 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1096 | } |
| 1097 | |
| 1098 | /* Function: Return the information in the worm data structure. |
| 1099 | * Arguments: vertex |
| 1100 | * Fails: never |
| 1101 | * Returns: Worm data formatted |
| 1102 | */ |
| 1103 | int |
| 1104 | QGtpcxx . . $ QGtp#::wormDatacxx . . $ QGtp#wormData(f47ee98913c22bd1). (char c, int i) |
| 1105 | { |
| 1106 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("worm_data "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 1107 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1108 | } |
| 1109 | |
| 1110 | /* Function: Return the cutstone field in the worm data structure. |
| 1111 | * Arguments: non-empty vertex |
| 1112 | * Fails: never |
| 1113 | * Returns: cutstone |
| 1114 | */ |
| 1115 | int |
| 1116 | QGtpcxx . . $ QGtp#::wormCutstonecxx . . $ QGtp#wormCutstone(f47ee98913c22bd1). (char c, int i) |
| 1117 | { |
| 1118 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("worm_cutstone "+c+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(i)); |
| 1119 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1120 | } |
| 1121 | |
| 1122 | /* Function: Tune the parameters for the move ordering in the tactical |
| 1123 | * reading. |
| 1124 | * Arguments: MOVE_ORDERING_PARAMETERS integers |
| 1125 | * Fails: incorrect arguments |
| 1126 | * Returns: nothing |
| 1127 | */ |
| 1128 | int |
| 1129 | QGtpcxx . . $ QGtp#::tuneMoveOrderingcxx . . $ QGtp#tuneMoveOrdering(7864480464b09eea). (int MOVE_ORDERING_PARAMETERS) |
| 1130 | { |
| 1131 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("tune_move_ordering "+cxx . . $ operator+(c76e440e68d4afec).intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(MOVE_ORDERING_PARAMETERS)); |
| 1132 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1133 | } |
| 1134 | |
| 1135 | /* Function: Echo the parameter |
| 1136 | * Arguments: string |
| 1137 | * Fails: never |
| 1138 | * Returns: nothing |
| 1139 | */ |
| 1140 | int |
| 1141 | QGtpcxx . . $ QGtp#::echocxx . . $ QGtp#echo(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# param) |
| 1142 | { |
| 1143 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("echo ")+cxx . . $ operator+(49e2485dc0bda598).param.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1144 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1145 | } |
| 1146 | |
| 1147 | /* Function: List all known commands |
| 1148 | * Arguments: none |
| 1149 | * Fails: never |
| 1150 | * Returns: list of known commands, one per line |
| 1151 | */ |
| 1152 | int |
| 1153 | QGtpcxx . . $ QGtp#::helpcxx . . $ QGtp#help(b126dc7c1de90089). () |
| 1154 | { |
| 1155 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("help"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 1156 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1157 | } |
| 1158 | |
| 1159 | /* Function: evaluate wether a command is known |
| 1160 | * Arguments: command word |
| 1161 | * Fails: never |
| 1162 | * Returns: true or false |
| 1163 | */ |
| 1164 | int |
| 1165 | QGtpcxx . . $ QGtp#::knownCommandcxx . . $ QGtp#knownCommand(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# s) |
| 1166 | { |
| 1167 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("known_command ")+cxx . . $ operator+(49e2485dc0bda598).s.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1168 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1169 | } |
| 1170 | |
| 1171 | QByteArraycxx . . $ QByteArray# QGtpcxx . . $ QGtp#::encodeCoorscxx . . $ QGtp#encodeCoors(4869bc8897d11479).(int x, int y) |
| 1172 | { |
| 1173 | if (x > 8) |
| 1174 | x++; |
| 1175 | QByteArraycxx . . $ QByteArray# resultcxx . . $ QByteArray#QByteArray(ced63f7c635d850d).; |
| 1176 | char c1 = x - 1 + 'A'; |
| 1177 | result.appendcxx . . $ QByteArray#append(1815c0e4073627df).(c1); |
| 1178 | result.appendcxx . . $ QByteArray#append(85c7caed82076bbb).(QStringcxx . . $ QString#QString(ced63f7c635d850d).().setNumcxx . . $ QString#setNum(6483560ce2afa901).(y).toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1179 | return resultcxx . . $ QByteArray#QByteArray(9f1b912973d89fea).; |
| 1180 | } |
| 1181 | |
| 1182 | QByteArraycxx . . $ QByteArray# QGtpcxx . . $ QGtp#::intToQByteArraycxx . . $ QGtp#intToQByteArray(85265d60c2bde7db).(int i) |
| 1183 | { |
| 1184 | return QStringcxx . . $ QString#QString(ced63f7c635d850d).().setNumcxx . . $ QString#setNum(6483560ce2afa901).(i).toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).(); |
| 1185 | } |
| 1186 | |
| 1187 | /* Function: Turn uncertainty reports from owl_attack |
| 1188 | * and owl_defend on or off. |
| 1189 | * Arguments: "on" or "off" |
| 1190 | * Fails: invalid argument |
| 1191 | * Returns: nothing |
| 1192 | */ |
| 1193 | int |
| 1194 | QGtpcxx . . $ QGtp#::reportUncertaintycxx . . $ QGtp#reportUncertainty(87a9b7c6fe1ccdba). (QStringcxx . . $ QString# s) |
| 1195 | { |
| 1196 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(QByteArraycxx . . $ QByteArray#QByteArray(34d26762b42c433a).("report_uncertainty ")+cxx . . $ operator+(49e2485dc0bda598).s.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1197 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1198 | } |
| 1199 | |
| 1200 | /* Function: List the stones of a worm |
| 1201 | * Arguments: the location |
| 1202 | * Fails: if called on an empty or off-board location |
| 1203 | * Returns: list of stones |
| 1204 | */ |
| 1205 | int |
| 1206 | QGtpcxx . . $ QGtp#::wormStonescxx . . $ QGtp#wormStones(b126dc7c1de90089).() |
| 1207 | { |
| 1208 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).("worm_stones"cxx . . $ QByteArray#QByteArray(34d26762b42c433a).); |
| 1209 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1210 | } |
| 1211 | |
| 1212 | int |
| 1213 | QGtpcxx . . $ QGtp#::shellcxx . . $ QGtp#shell(87a9b7c6fe1ccdba).(QStringcxx . . $ QString# s) |
| 1214 | { |
| 1215 | fflushcxx . . $ QGtp#fflush(ddc4016aa177531b).(s.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 1216 | return waitResponsecxx . . $ QGtp#waitResponse(b126dc7c1de90089).(); |
| 1217 | } |
| 1218 |