| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009 by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | |
| 23 | #include "move.h"cxx . . $ `<file>/src/game_tree/move.h`/ |
| 24 | #include "matrix.h"cxx . . $ `<file>/src/game_tree/matrix.h`/ |
| 25 | #include "group.h"cxx . . $ `<file>/src/game_tree/group.h`/ |
| 26 | |
| 27 | Movecxx . . $ Move#::Movecxx . . $ Move#Move(d4f767463ce0a6b3).(int board_size) |
| 28 | { |
| 29 | parentcxx . . $ Move#parent. = soncxx . . $ Move#son. = brothercxx . . $ Move#brother. = markercxx . . $ Move#marker. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 30 | stoneColorcxx . . $ Move#stoneColor. = stoneNonecxx . . $ stoneNone.; |
| 31 | xcxx . . $ Move#x. = ycxx . . $ Move#y. = -1; |
| 32 | gamePhasecxx . . $ Move#gamePhase. = phaseOngoingcxx . . $ phaseOngoing.; |
| 33 | moveNumcxx . . $ Move#moveNum. = 0; |
| 34 | terrMarkedcxx . . $ Move#terrMarked. = false; |
| 35 | capturesBlackcxx . . $ Move#capturesBlack. = capturesWhitecxx . . $ Move#capturesWhite. = 0; |
| 36 | checkedcxx . . $ Move#checked. = true; |
| 37 | //fastLoadMarkDict = NULL; |
| 38 | scoredcxx . . $ Move#scored. = false; |
| 39 | scoreWhitecxx . . $ Move#scoreWhite. = scoreBlackcxx . . $ Move#scoreBlack. = 0; |
| 40 | PLinfocxx . . $ Move#PLinfo. = false; |
| 41 | timeinfocxx . . $ Move#timeinfo. = false; |
| 42 | handicapMovecxx . . $ Move#handicapMove. = false; |
| 43 | matrixcxx . . $ Move#matrix. = new Matrixcxx . . $ Matrix#Matrix(d4f767463ce0a6b3).(board_size); |
| 44 | } |
| 45 | |
| 46 | Movecxx . . $ Move#::Movecxx . . $ Move#Move(b008f1e121f1e0ed).(StoneColorcxx . . $ StoneColor# c, int mx, int my, int n, GamePhasecxx . . $ GamePhase# phase, const Matrixcxx . . $ Matrix# &mat, bool clearAllMarks, const QStringcxx . . $ QString# &s) |
| 47 | : stoneColorcxx . . $ Move#stoneColor.(c), xcxx . . $ Move#x.(mx), ycxx . . $ Move#y.(my), moveNumcxx . . $ Move#moveNum.(n), gamePhasecxx . . $ Move#gamePhase.(phase), commentcxx . . $ Move#comment.(s) |
| 48 | { |
| 49 | parentcxx . . $ Move#parent. = soncxx . . $ Move#son. = brothercxx . . $ Move#brother. = markercxx . . $ Move#marker. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 50 | capturesBlackcxx . . $ Move#capturesBlack. = capturesWhitecxx . . $ Move#capturesWhite. = 0; |
| 51 | terrMarkedcxx . . $ Move#terrMarked. = false; |
| 52 | checkedcxx . . $ Move#checked. = true; |
| 53 | scoredcxx . . $ Move#scored. = false; |
| 54 | scoreWhitecxx . . $ Move#scoreWhite. = scoreBlackcxx . . $ Move#scoreBlack. = 0; |
| 55 | PLinfocxx . . $ Move#PLinfo. = false; |
| 56 | timeinfocxx . . $ Move#timeinfo. = false; |
| 57 | handicapMovecxx . . $ Move#handicapMove. = false; |
| 58 | matrixcxx . . $ Move#matrix. = new Matrixcxx . . $ Matrix#Matrix(6427e280fdeb4614).(mat, clearAllMarks); |
| 59 | } |
| 60 | |
| 61 | Movecxx . . $ Move#::Movecxx . . $ Move#Move(5c1f83d66f14598a).(StoneColorcxx . . $ StoneColor# c, int mx, int my, int n, GamePhasecxx . . $ GamePhase# phase, const QStringcxx . . $ QString# &s) |
| 62 | : stoneColorcxx . . $ Move#stoneColor.(c), xcxx . . $ Move#x.(mx), ycxx . . $ Move#y.(my), moveNumcxx . . $ Move#moveNum.(n), gamePhasecxx . . $ Move#gamePhase.(phase), commentcxx . . $ Move#comment.(s) |
| 63 | { |
| 64 | parentcxx . . $ Move#parent. = soncxx . . $ Move#son. = brothercxx . . $ Move#brother. = markercxx . . $ Move#marker. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 65 | capturesBlackcxx . . $ Move#capturesBlack. = capturesWhitecxx . . $ Move#capturesWhite. = 0; |
| 66 | terrMarkedcxx . . $ Move#terrMarked. = false; |
| 67 | checkedcxx . . $ Move#checked. = false; |
| 68 | matrixcxx . . $ Move#matrix. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 69 | scoredcxx . . $ Move#scored. = false; |
| 70 | scoreWhitecxx . . $ Move#scoreWhite. = scoreBlackcxx . . $ Move#scoreBlack. = 0; |
| 71 | PLinfocxx . . $ Move#PLinfo. = false; |
| 72 | timeinfocxx . . $ Move#timeinfo. = false; |
| 73 | handicapMovecxx . . $ Move#handicapMove. = false; |
| 74 | } |
| 75 | |
| 76 | Movecxx . . $ Move#::Movecxx . . $ Move#Move(752bbe91abdcf632).(Movecxx . . $ Move# *_parent, StoneColorcxx . . $ StoneColor# _c, int _x, int _y) |
| 77 | : stoneColorcxx . . $ Move#stoneColor.(_c), xcxx . . $ Move#x.(_x), ycxx . . $ Move#y.(_y) |
| 78 | { |
| 79 | soncxx . . $ Move#son. = brothercxx . . $ Move#brother. = markercxx . . $ Move#marker. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 80 | parentcxx . . $ Move#parent. = _parent; |
| 81 | moveNumcxx . . $ Move#moveNum. = parentcxx . . $ Move#parent.->moveNumcxx . . $ Move#moveNum.+1; |
| 82 | gamePhasecxx . . $ Move#gamePhase. = parentcxx . . $ Move#parent.->gamePhasecxx . . $ Move#gamePhase.; |
| 83 | capturesBlackcxx . . $ Move#capturesBlack. = parentcxx . . $ Move#parent.->capturesBlackcxx . . $ Move#capturesBlack.; |
| 84 | capturesWhitecxx . . $ Move#capturesWhite. = parentcxx . . $ Move#parent.->capturesWhitecxx . . $ Move#capturesWhite.; |
| 85 | matrixcxx . . $ Move#matrix. = new Matrixcxx . . $ Matrix#Matrix(6427e280fdeb4614).(*(parentcxx . . $ Move#parent.->matrixcxx . . $ Move#matrix.), true); |
| 86 | terrMarkedcxx . . $ Move#terrMarked. = false; |
| 87 | checkedcxx . . $ Move#checked. = false; |
| 88 | scoredcxx . . $ Move#scored. = false; |
| 89 | scoreWhitecxx . . $ Move#scoreWhite. = scoreBlackcxx . . $ Move#scoreBlack. = 0; |
| 90 | PLinfocxx . . $ Move#PLinfo. = false; |
| 91 | timeinfocxx . . $ Move#timeinfo. = false; |
| 92 | handicapMovecxx . . $ Move#handicapMove. = false; |
| 93 | // current node has no son? |
| 94 | if (parentcxx . . $ Move#parent.->soncxx . . $ Move#son. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 95 | { |
| 96 | parentcxx . . $ Move#parent.->soncxx . . $ Move#son. = this; |
| 97 | } |
| 98 | // A son found. Add the new node as farest right brother of that son |
| 99 | else |
| 100 | { |
| 101 | parentcxx . . $ Move#parent.->soncxx . . $ Move#son.->addBrothercxx . . $ Move#addBrother(490cd2a4f5caa810).(this); |
| 102 | } |
| 103 | |
| 104 | // Execute move |
| 105 | if (xcxx . . $ Move#x. != PASS_XYcxx . . $ `src/defines.h:38:9`! || ycxx . . $ Move#y. != PASS_XYcxx . . $ `src/defines.h:38:9`!) |
| 106 | { |
| 107 | int lastCaptures = matrixcxx . . $ Move#matrix.->makeMovecxx . . $ Matrix#makeMove(bed22547599c466d).(xcxx . . $ Move#x., ycxx . . $ Move#y., stoneColorcxx . . $ Move#stoneColor.); |
| 108 | |
| 109 | if (stoneColorcxx . . $ Move#stoneColor. == stoneBlackcxx . . $ stoneBlack.) |
| 110 | capturesBlackcxx . . $ Move#capturesBlack. += lastCaptures; |
| 111 | else if (stoneColorcxx . . $ Move#stoneColor. == stoneWhitecxx . . $ stoneWhite.) |
| 112 | capturesWhitecxx . . $ Move#capturesWhite. += lastCaptures; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | Movecxx . . $ Move#::~cxx . . $ Move#`~Move`(ced63f7c635d850d).Movecxx . . $ Move#() |
| 117 | { |
| 118 | while (soncxx . . $ Move#son.) |
| 119 | delete soncxx . . $ Move#son.; |
| 120 | if (parentcxx . . $ Move#parent.) |
| 121 | { |
| 122 | if (parentcxx . . $ Move#parent.->markercxx . . $ Move#marker. == this) |
| 123 | parentcxx . . $ Move#parent.->markercxx . . $ Move#marker. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 124 | Movecxx . . $ Move# * tmp = getPrevBrothercxx . . $ Move#getPrevBrother(81447a345d48a217).(); |
| 125 | if (tmp) |
| 126 | tmp->brothercxx . . $ Move#brother. = brothercxx . . $ Move#brother.; |
| 127 | else |
| 128 | parentcxx . . $ Move#parent.->soncxx . . $ Move#son. = brothercxx . . $ Move#brother.; |
| 129 | } |
| 130 | delete matrixcxx . . $ Move#matrix.; |
| 131 | } |
| 132 | |
| 133 | Movecxx . . $ Move# *Movecxx . . $ Move#::getLastMovecxx . . $ Move#getLastMove(64a469cb2ad0f61a).(bool followMarker) |
| 134 | { |
| 135 | Movecxx . . $ Move# * tmp = this; |
| 136 | // Go down the current branch, use the marker if possible to remember a previously used path |
| 137 | while (tmp->soncxx . . $ Move#son.) |
| 138 | tmp = ( (followMarker && (tmp->markercxx . . $ Move#marker. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) ? tmp->markercxx . . $ Move#marker. : tmp->soncxx . . $ Move#son.); |
| 139 | return tmp; |
| 140 | } |
| 141 | |
| 142 | Movecxx . . $ Move# *Movecxx . . $ Move#::getPrevBrothercxx . . $ Move#getPrevBrother(81447a345d48a217).() |
| 143 | { |
| 144 | if (parentcxx . . $ Move#parent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || parentcxx . . $ Move#parent.->soncxx . . $ Move#son. == this) |
| 145 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 146 | Movecxx . . $ Move# * tmp = parentcxx . . $ Move#parent.->soncxx . . $ Move#son.; |
| 147 | while (tmp->brothercxx . . $ Move#brother. != this) |
| 148 | tmp = tmp->brothercxx . . $ Move#brother.; |
| 149 | return tmp; |
| 150 | } |
| 151 | |
| 152 | bool Movecxx . . $ Move#::isInMainBranchcxx . . $ Move#isInMainBranch(50ce9a9e25b4a850).() const |
| 153 | { |
| 154 | const Movecxx . . $ Move# * m = this; |
| 155 | while(m->parentcxx . . $ Move#parent. && m->parentcxx . . $ Move#parent.->soncxx . . $ Move#son. == m) |
| 156 | m = m->parentcxx . . $ Move#parent.; |
| 157 | return (m->parentcxx . . $ Move#parent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * returns a string representing the move in SGF format |
| 162 | */ |
| 163 | const QStringcxx . . $ QString# Movecxx . . $ Move#::saveMovecxx . . $ Move#saveMove(8bafd9946dc70e68).(bool isRoot) |
| 164 | { |
| 165 | QStringcxx . . $ QString# strcxx . . $ QString#QString(ced63f7c635d850d).; |
| 166 | |
| 167 | if (!isRoot && !handicapMovecxx . . $ Move#handicapMove. ) |
| 168 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). ";"; //"\n;"; |
| 169 | |
| 170 | if (xcxx . . $ Move#x. != -1 && ycxx . . $ Move#y. != -1) |
| 171 | { |
| 172 | if(gamePhasecxx . . $ Move#gamePhase. == phaseEditcxx . . $ phaseEdit. && matrixcxx . . $ Move#matrix.->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(xcxx . . $ Move#x.,ycxx . . $ Move#y.) == stoneErasecxx . . $ stoneErase.) {} |
| 173 | else |
| 174 | { |
| 175 | // Write something like 'B[aa]' |
| 176 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). stoneColorcxx . . $ Move#stoneColor. == stoneBlackcxx . . $ stoneBlack. ? "B" : "W"; |
| 177 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). Matrixcxx . . $ Matrix#::coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(xcxx . . $ Move#x.-1, ycxx . . $ Move#y.-1) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | // Save edited moves (including handicap) |
| 182 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). matrixcxx . . $ Move#matrix.->saveEditedMovescxx . . $ Matrix#saveEditedMoves(58a83039bbc051dc).(parentcxx . . $ Move#parent. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? parentcxx . . $ Move#parent.->getMatrixcxx . . $ Move#getMatrix(a22259058712982).() : 0); |
| 183 | |
| 184 | // Save marks |
| 185 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). matrixcxx . . $ Move#matrix.->saveMarkscxx . . $ Matrix#saveMarks(ea4b39313763ec41).(); |
| 186 | |
| 187 | // Add nodename, if we have one |
| 188 | if (!nodeNamecxx . . $ Move#nodeName..isNullcxx . . $ QString#isNull(50ce9a9e25b4a850).() && !nodeNamecxx . . $ Move#nodeName..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 189 | { |
| 190 | // simpletext |
| 191 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "N["; |
| 192 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). nodeNamecxx . . $ Move#nodeName.; |
| 193 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "]"; |
| 194 | } |
| 195 | |
| 196 | // Add next move's color |
| 197 | if (PLinfocxx . . $ Move#PLinfo.) |
| 198 | { |
| 199 | if (PLnextMovecxx . . $ Move#PLnextMove. == stoneBlackcxx . . $ stoneBlack.) |
| 200 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "PL[B]"; |
| 201 | else |
| 202 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "PL[W]"; |
| 203 | } |
| 204 | |
| 205 | // Add comment, if we have one |
| 206 | if (!commentcxx . . $ Move#comment..isNullcxx . . $ QString#isNull(50ce9a9e25b4a850).() && !commentcxx . . $ Move#comment..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 207 | { |
| 208 | // text |
| 209 | QStringcxx . . $ QString# tmp = commentcxx . . $ QString#QString(132dd6869045752b).; |
| 210 | int pos = 0; |
| 211 | while (( (pos = tmp.indexOfcxx . . $ QString#indexOf(a1e52806cd31c200).("]"cxx . . $ QString#QString(85c52e162fed56f9)., pos)) != -1) && (static_cast<signed int>(pos) < tmp.lengthcxx . . $ QString#length(455f465bc33b4cdf).())) |
| 212 | { |
| 213 | tmp.replacecxx . . $ QString#replace(2ea42a074cd0ed6b).(pos, 1, "\\]"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 214 | pos += 2; |
| 215 | } |
| 216 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "C["; |
| 217 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). tmp; |
| 218 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "]"; |
| 219 | } |
| 220 | |
| 221 | // time info |
| 222 | if (timeinfocxx . . $ Move#timeinfo. && !isRoot && (int) timeLeftcxx . . $ Move#timeLeft.) |
| 223 | { |
| 224 | if (stoneColorcxx . . $ Move#stoneColor. == stoneBlackcxx . . $ stoneBlack.) |
| 225 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "BL["; |
| 226 | else |
| 227 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "WL["; |
| 228 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(timeLeftcxx . . $ Move#timeLeft.); |
| 229 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "]"; |
| 230 | |
| 231 | // open moves info |
| 232 | if (openMovescxx . . $ Move#openMoves. > 0) |
| 233 | { |
| 234 | if (stoneColorcxx . . $ Move#stoneColor. == stoneBlackcxx . . $ stoneBlack.) |
| 235 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "OB["; |
| 236 | else |
| 237 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "OW["; |
| 238 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(openMovescxx . . $ Move#openMoves.); |
| 239 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "]"; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // Add unknown properties, if we have some |
| 244 | if (!unknownPropertycxx . . $ Move#unknownProperty..isNullcxx . . $ QString#isNull(50ce9a9e25b4a850).() && !unknownPropertycxx . . $ Move#unknownProperty..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 245 | { |
| 246 | // complete property |
| 247 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). unknownPropertycxx . . $ Move#unknownProperty.; |
| 248 | } |
| 249 | |
| 250 | return strcxx . . $ QString#QString(28715ad661ad3cec).; |
| 251 | } |
| 252 | |
| 253 | bool Movecxx . . $ Move#::isPassMovecxx . . $ Move#isPassMove(c9857a73d68e59ba).() |
| 254 | { |
| 255 | if ((xcxx . . $ Move#x.==PASS_XYcxx . . $ `src/defines.h:38:9`!) && (ycxx . . $ Move#y.==PASS_XYcxx . . $ `src/defines.h:38:9`!)) |
| 256 | return true; |
| 257 | |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | int Movecxx . . $ Move#::getNumBrotherscxx . . $ Move#getNumBrothers(b126dc7c1de90089).() |
| 262 | { |
| 263 | if (parentcxx . . $ Move#parent. ==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 264 | return 0; |
| 265 | |
| 266 | Movecxx . . $ Move# *tmp = parentcxx . . $ Move#parent.->soncxx . . $ Move#son.; |
| 267 | int counter = 0; |
| 268 | |
| 269 | while ((tmp = tmp->brothercxx . . $ Move#brother.) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 270 | counter ++; |
| 271 | |
| 272 | return counter; |
| 273 | } |
| 274 | |
| 275 | int Movecxx . . $ Move#::getNumSonscxx . . $ Move#getNumSons(b126dc7c1de90089).() |
| 276 | { |
| 277 | Movecxx . . $ Move# *tmp = soncxx . . $ Move#son.; |
| 278 | int counter = 0; |
| 279 | |
| 280 | while (tmp) |
| 281 | { |
| 282 | tmp = tmp->brothercxx . . $ Move#brother.; |
| 283 | counter ++; |
| 284 | } |
| 285 | |
| 286 | return counter; |
| 287 | } |
| 288 | |
| 289 | bool Movecxx . . $ Move#::hasParentcxx . . $ Move#hasParent(c9857a73d68e59ba).() |
| 290 | { |
| 291 | return (parentcxx . . $ Move#parent. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 292 | } |
| 293 | |
| 294 | bool Movecxx . . $ Move#::hasPrevBrothercxx . . $ Move#hasPrevBrother(c9857a73d68e59ba).() |
| 295 | { |
| 296 | if (parentcxx . . $ Move#parent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 297 | return false; |
| 298 | else |
| 299 | return (this != parentcxx . . $ Move#parent.->soncxx . . $ Move#son.); |
| 300 | } |
| 301 | |
| 302 | bool Movecxx . . $ Move#::hasNextBrothercxx . . $ Move#hasNextBrother(c9857a73d68e59ba).() |
| 303 | { |
| 304 | return (brothercxx . . $ Move#brother. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 305 | } |
| 306 | |
| 307 | void Movecxx . . $ Move#::addBrothercxx . . $ Move#addBrother(490cd2a4f5caa810).(Movecxx . . $ Move# * b) |
| 308 | { |
| 309 | Movecxx . . $ Move# *tmp = this; |
| 310 | |
| 311 | // Find brother farest right |
| 312 | while (tmp->brothercxx . . $ Move#brother. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 313 | tmp = tmp->brothercxx . . $ Move#brother.; |
| 314 | |
| 315 | tmp->brothercxx . . $ Move#brother. = b; |
| 316 | b->parentcxx . . $ Move#parent. = tmp->parentcxx . . $ Move#parent.; |
| 317 | b->setTimeinfocxx . . $ Move#setTimeinfo(b45ddcbc8423892c).(false); //whats this for FIXME? |
| 318 | } |
| 319 | |
| 320 | void Movecxx . . $ Move#::addStonecxx . . $ Move#addStone(e6b2860cd25699f2).(StoneColorcxx . . $ StoneColor# c, int x, int y) |
| 321 | { |
| 322 | if ((x < 1) || (x > matrixcxx . . $ Move#matrix.->getSizecxx . . $ Matrix#getSize(455f465bc33b4cdf).()) || (y < 1) || (y > matrixcxx . . $ Move#matrix.->getSizecxx . . $ Matrix#getSize(455f465bc33b4cdf).())) |
| 323 | return; |
| 324 | |
| 325 | if (! parentcxx . . $ Move#parent.) |
| 326 | { |
| 327 | setHandicapMovecxx . . $ Move#setHandicapMove(b45ddcbc8423892c).(true); |
| 328 | setMoveNumbercxx . . $ Move#setMoveNumber(d4f767463ce0a6b3).(0); //TODO : make sure this is the proper way |
| 329 | setXcxx . . $ Move#setX(d4f767463ce0a6b3).(-1); |
| 330 | setYcxx . . $ Move#setY(d4f767463ce0a6b3).(-1); |
| 331 | setColorcxx . . $ Move#setColor(42096433316d3db3).(stoneBlackcxx . . $ stoneBlack.); // So that it is white's turn |
| 332 | } |
| 333 | |
| 334 | matrixcxx . . $ Move#matrix.->insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(x, y, c, getGamePhasecxx . . $ Move#getGamePhase(77809a1e68c5b791).() == phaseEditcxx . . $ phaseEdit.); |
| 335 | } |
| 336 | |
| 337 | bool Movecxx . . $ Move#::checkMoveIsValidcxx . . $ Move#checkMoveIsValid(d30022d4f7f7716f).(StoneColorcxx . . $ StoneColor# c, int x, int y) |
| 338 | { |
| 339 | if (x == PASS_XYcxx . . $ `src/defines.h:38:9`! && y == PASS_XYcxx . . $ `src/defines.h:38:9`!) |
| 340 | return true; |
| 341 | |
| 342 | if (x < 1 || x > matrixcxx . . $ Move#matrix.->getSizecxx . . $ Matrix#getSize(455f465bc33b4cdf).() || y < 1 || y > matrixcxx . . $ Move#matrix.->getSizecxx . . $ Matrix#getSize(455f465bc33b4cdf).()) |
| 343 | { |
| 344 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("Invalid position: %d/%d", x, y); |
| 345 | return false; |
| 346 | } |
| 347 | |
| 348 | /* special case, we're erasing a stone */ |
| 349 | if(c == stoneErasecxx . . $ stoneErase.) |
| 350 | { |
| 351 | return (matrixcxx . . $ Move#matrix.->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x,y) != stoneNonecxx . . $ stoneNone.); |
| 352 | } |
| 353 | |
| 354 | // If there is already a stone at (x,y) do nothing |
| 355 | if ((matrixcxx . . $ Move#matrix.->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x, y) == stoneBlackcxx . . $ stoneBlack.) || |
| 356 | (matrixcxx . . $ Move#matrix.->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x, y) == stoneWhitecxx . . $ stoneWhite.)) |
| 357 | return false; |
| 358 | |
| 359 | // Check for ko |
| 360 | if (matrixcxx . . $ Move#matrix.->getMarkAtcxx . . $ Matrix#getMarkAt(cd452d1956ab952a).(x,y) & markKoMarkercxx . . $ markKoMarker.) |
| 361 | return false; |
| 362 | |
| 363 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Groupcxx . . $ Group# *> visitedcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 364 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Group *>::iteratorcxx . . $ std/vector#iterator# it_visitedcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 365 | int lastCaptures = matrixcxx . . $ Move#matrix.->checkStoneCapturescxx . . $ Matrix#checkStoneCaptures(3f4db0380f904985).(c,x,y,visited); |
| 366 | // FIXME should not have to delete these groups here |
| 367 | for (it_visited =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(fec428d078a8964d). visited.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it_visited <cxx . . $ __gnu_cxx/`operator<`(30ee64f2df4eef8b). visited.endcxx . . $ std/vector#end(55a6de06420d4903).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(1613faa01bc3d014).it_visited) |
| 368 | { |
| 369 | delete (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited); |
| 370 | } |
| 371 | |
| 372 | return (lastCaptures >= 0); |
| 373 | } |
| 374 | |
| 375 | Movecxx . . $ Move# *Movecxx . . $ Move#::hasSoncxx . . $ Move#hasSon(1b9ccd6dde28afc7).(StoneColorcxx . . $ StoneColor# c, int x, int y) |
| 376 | { |
| 377 | Movecxx . . $ Move# *tmp = soncxx . . $ Move#son.; |
| 378 | while (tmp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 379 | if ((tmp->getColorcxx . . $ Move#getColor(6680c74b05d375a4).() == c) && (tmp->getXcxx . . $ Move#getX(455f465bc33b4cdf).() == x) && (tmp->getYcxx . . $ Move#getY(455f465bc33b4cdf).() == y)) |
| 380 | break; |
| 381 | tmp = tmp->brothercxx . . $ Move#brother.; |
| 382 | }; |
| 383 | return tmp; |
| 384 | } |
| 385 | |
| 386 | Movecxx . . $ Move# *Movecxx . . $ Move#::makeMovecxx . . $ Move#makeMove(b73c42e1a544db20).(StoneColorcxx . . $ StoneColor# c, int x, int y, bool force) |
| 387 | { |
| 388 | if (force || checkMoveIsValidcxx . . $ Move#checkMoveIsValid(d30022d4f7f7716f).(c, x, y)) |
| 389 | return new Movecxx . . $ Move#(this, c, x, y); |
| 390 | else |
| 391 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 392 | } |
| 393 | |
| 394 | Movecxx . . $ Move# *Movecxx . . $ Move#::makePasscxx . . $ Move#makePass(81447a345d48a217).() |
| 395 | { |
| 396 | return makeMovecxx . . $ Move#makeMove(b73c42e1a544db20).(stoneColorcxx . . $ Move#stoneColor. == stoneBlackcxx . . $ stoneBlack. ? stoneWhitecxx . . $ stoneWhite. : stoneBlackcxx . . $ stoneBlack., PASS_XYcxx . . $ `src/defines.h:38:9`!, PASS_XYcxx . . $ `src/defines.h:38:9`!, true); |
| 397 | } |
| 398 | |
| 399 | StoneColorcxx . . $ StoneColor# Movecxx . . $ Move#::whoIsOnTurncxx . . $ Move#whoIsOnTurn(5202307a42d70465).() |
| 400 | { |
| 401 | if (getPLinfocxx . . $ Move#getPLinfo(c9857a73d68e59ba).()) |
| 402 | // color of next stone is same as current |
| 403 | return getPLnextMovecxx . . $ Move#getPLnextMove(5202307a42d70465).(); |
| 404 | |
| 405 | return (stoneColorcxx . . $ Move#stoneColor. == stoneBlackcxx . . $ stoneBlack. ? stoneWhitecxx . . $ stoneWhite. : stoneBlackcxx . . $ stoneBlack.); |
| 406 | } |