| 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 "matrix.h"cxx . . $ `<file>/src/game_tree/matrix.h`/ |
| 24 | #include "group.h"cxx . . $ `<file>/src/game_tree/group.h`/ |
| 25 | |
| 26 | Matrixcxx . . $ Matrix#::Matrixcxx . . $ Matrix#Matrix(d4f767463ce0a6b3).(int s) |
| 27 | : sizecxx . . $ Matrix#size.(s) |
| 28 | { |
| 29 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(size > 0 && size <= 36); |
| 30 | |
| 31 | matrixcxx . . $ Matrix#matrix. = new unsigned short[sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.]; |
| 32 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(matrix); |
| 33 | |
| 34 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; i++) |
| 35 | matrixcxx . . $ Matrix#matrix.[i] = stoneNonecxx . . $ stoneNone.; |
| 36 | } |
| 37 | |
| 38 | Matrixcxx . . $ Matrix#::Matrixcxx . . $ Matrix#Matrix(6427e280fdeb4614).(const Matrixcxx . . $ Matrix# &m, bool cleanup) |
| 39 | : sizecxx . . $ Matrix#size.(m.sizecxx . . $ Matrix#size.) |
| 40 | { |
| 41 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(size > 0 && size <= 36); |
| 42 | |
| 43 | matrixcxx . . $ Matrix#matrix. = new unsigned short[sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.]; |
| 44 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(matrix); |
| 45 | |
| 46 | unsigned short mask = stoneWhitecxx . . $ stoneWhite. | stoneBlackcxx . . $ stoneBlack.; |
| 47 | if (!cleanup) |
| 48 | mask |= markAllcxx . . $ markAll.; |
| 49 | mask &= (~markKoMarkercxx . . $ markKoMarker.); |
| 50 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; ++i) |
| 51 | matrixcxx . . $ Matrix#matrix.[i] = m.matrixcxx . . $ Matrix#matrix.[i] & mask; |
| 52 | } |
| 53 | |
| 54 | Matrixcxx . . $ Matrix#::~cxx . . $ Matrix#`~Matrix`(ced63f7c635d850d).Matrixcxx . . $ Matrix#() |
| 55 | { |
| 56 | delete[] matrixcxx . . $ Matrix#matrix.; |
| 57 | } |
| 58 | |
| 59 | void Matrixcxx . . $ Matrix#::insertStonecxx . . $ Matrix#insertStone(86392494ac0cc61f).(int key, StoneColorcxx . . $ StoneColor# c, bool fEdit) |
| 60 | { |
| 61 | matrixcxx . . $ Matrix#matrix.[key] &= (~stoneErasecxx . . $ stoneErase.); |
| 62 | matrixcxx . . $ Matrix#matrix.[key] |= c; |
| 63 | if(fEdit) |
| 64 | matrixcxx . . $ Matrix#matrix.[key] |= MX_STONEEDITcxx . . $ `src/game_tree/matrix.h:35:9`!; |
| 65 | } |
| 66 | |
| 67 | void Matrixcxx . . $ Matrix#::insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(int x, int y, StoneColorcxx . . $ StoneColor# c, bool fEdit) |
| 68 | { |
| 69 | insertStonecxx . . $ Matrix#insertStone(86392494ac0cc61f).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y),c,fEdit); |
| 70 | } |
| 71 | |
| 72 | StoneColorcxx . . $ StoneColor# Matrixcxx . . $ Matrix#::getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(int key) const |
| 73 | { |
| 74 | return (StoneColorcxx . . $ StoneColor#) (matrixcxx . . $ Matrix#matrix.[key] & 0x3); |
| 75 | } |
| 76 | |
| 77 | StoneColorcxx . . $ StoneColor# Matrixcxx . . $ Matrix#::getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(int x, int y) |
| 78 | { |
| 79 | return getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)); |
| 80 | } |
| 81 | |
| 82 | bool Matrixcxx . . $ Matrix#::isStoneDeadcxx . . $ Matrix#isStoneDead(cf9ef193275fa6d8).(int x, int y) |
| 83 | { |
| 84 | return (matrixcxx . . $ Matrix#matrix.[coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)] & MX_STONEDEADcxx . . $ `src/game_tree/matrix.h:34:9`!); |
| 85 | } |
| 86 | |
| 87 | MarkTypecxx . . $ MarkType# Matrixcxx . . $ Matrix#::getMarkAtcxx . . $ Matrix#getMarkAt(49bf564c8ddc54a6).(int key) const |
| 88 | { |
| 89 | return (MarkTypecxx . . $ MarkType#) (matrixcxx . . $ Matrix#matrix.[key] & markAllcxx . . $ markAll.); |
| 90 | } |
| 91 | |
| 92 | MarkTypecxx . . $ MarkType# Matrixcxx . . $ Matrix#::getMarkAtcxx . . $ Matrix#getMarkAt(cd452d1956ab952a).(int x, int y) |
| 93 | { |
| 94 | return getMarkAtcxx . . $ Matrix#getMarkAt(49bf564c8ddc54a6).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)); |
| 95 | } |
| 96 | |
| 97 | void Matrixcxx . . $ Matrix#::insertMarkcxx . . $ Matrix#insertMark(2fb52c50f1893bf2).(int x, int y, MarkTypecxx . . $ MarkType# t) |
| 98 | { |
| 99 | matrixcxx . . $ Matrix#matrix.[coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)] &= (~markAllcxx . . $ markAll.); |
| 100 | matrixcxx . . $ Matrix#matrix.[coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)] |= t; |
| 101 | } |
| 102 | |
| 103 | void Matrixcxx . . $ Matrix#::removeMarkcxx . . $ Matrix#removeMark(3e454b8ccf442868).(int x, int y) |
| 104 | { |
| 105 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(x > 0 && x <= size && |
| 106 | y > 0 && y <= size); |
| 107 | |
| 108 | matrixcxx . . $ Matrix#matrix.[coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)] &= (~markAllcxx . . $ markAll.); |
| 109 | markTextscxx . . $ Matrix#markTexts..removecxx . . $ QHash#remove(dd8e59d271e40448).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)); |
| 110 | } |
| 111 | |
| 112 | void Matrixcxx . . $ Matrix#::clearAllMarkscxx . . $ Matrix#clearAllMarks(49f6e7a06ebc5aa8).() |
| 113 | { |
| 114 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; ++i) |
| 115 | { |
| 116 | matrixcxx . . $ Matrix#matrix.[i] &= (~markAllcxx . . $ markAll.); |
| 117 | } |
| 118 | markTextscxx . . $ Matrix#markTexts..clearcxx . . $ QHash#clear(49f6e7a06ebc5aa8).(); |
| 119 | } |
| 120 | |
| 121 | void Matrixcxx . . $ Matrix#::clearTerritoryMarkscxx . . $ Matrix#clearTerritoryMarks(49f6e7a06ebc5aa8).() |
| 122 | { |
| 123 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; ++i) |
| 124 | matrixcxx . . $ Matrix#matrix.[i] &= (~markTerrDamecxx . . $ markTerrDame.); |
| 125 | } |
| 126 | |
| 127 | // Called when leaving score mode |
| 128 | void Matrixcxx . . $ Matrix#::absMatrixcxx . . $ Matrix#absMatrix(49f6e7a06ebc5aa8).() |
| 129 | { |
| 130 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; ++i) |
| 131 | { |
| 132 | matrixcxx . . $ Matrix#matrix.[i] &= ~(MX_STONEDEADcxx . . $ `src/game_tree/matrix.h:34:9`! | MX_STONEEDITcxx . . $ `src/game_tree/matrix.h:35:9`!); |
| 133 | if (getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(i) == stoneErasecxx . . $ stoneErase.) |
| 134 | insertStonecxx . . $ Matrix#insertStone(86392494ac0cc61f).(i, stoneNonecxx . . $ stoneNone.); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | void Matrixcxx . . $ Matrix#::setMarkTextcxx . . $ Matrix#setMarkText(c89d651b24440698).(int x, int y, const QStringcxx . . $ QString# &txt) |
| 139 | { |
| 140 | markTextscxx . . $ Matrix#markTexts..insertcxx . . $ QHash#insert(d77b19c31d2eb147).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y),txt); |
| 141 | } |
| 142 | |
| 143 | const QStringcxx . . $ QString# Matrixcxx . . $ Matrix#::getMarkTextcxx . . $ Matrix#getMarkText(ff5dcb9213a676d0).(int x, int y) |
| 144 | { |
| 145 | return markTextscxx . . $ Matrix#markTexts..valuecxx . . $ QHash#value(bfda1f1f965926d4).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)); |
| 146 | } |
| 147 | |
| 148 | /* |
| 149 | * returns a string representing the marks in the matrix, in SGF format |
| 150 | */ |
| 151 | const QStringcxx . . $ QString# Matrixcxx . . $ Matrix#::saveMarkscxx . . $ Matrix#saveMarks(ea4b39313763ec41).() |
| 152 | { |
| 153 | QStringcxx . . $ QString# txtcxx . . $ QString#QString(ced63f7c635d850d)., sSQ = ""cxx . . $ QString#QString(85c52e162fed56f9)., sCR = ""cxx . . $ QString#QString(85c52e162fed56f9)., sTR = ""cxx . . $ QString#QString(85c52e162fed56f9)., sMA = ""cxx . . $ QString#QString(85c52e162fed56f9)., sLB = ""cxx . . $ QString#QString(85c52e162fed56f9)., sTB = ""cxx . . $ QString#QString(85c52e162fed56f9)., sTW = ""cxx . . $ QString#QString(85c52e162fed56f9).; |
| 154 | int i, j, colw = 0, colb = 0; |
| 155 | |
| 156 | for (i=0; i<sizecxx . . $ Matrix#size.; i++) |
| 157 | { |
| 158 | for (j=0; j<sizecxx . . $ Matrix#size.; j++) |
| 159 | { |
| 160 | switch (getMarkAtcxx . . $ Matrix#getMarkAt(cd452d1956ab952a).(i + 1, j + 1)) |
| 161 | { |
| 162 | case markSquarecxx . . $ markSquare.: |
| 163 | if (sSQ.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 164 | sSQ +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "SQ"; |
| 165 | sSQ +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 166 | break; |
| 167 | case markCirclecxx . . $ markCircle.: |
| 168 | if (sCR.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 169 | sCR +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "CR"; |
| 170 | sCR +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 171 | break; |
| 172 | case markTrianglecxx . . $ markTriangle.: |
| 173 | if (sTR.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 174 | sTR +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "TR"; |
| 175 | sTR +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 176 | break; |
| 177 | case markCrosscxx . . $ markCross.: |
| 178 | if (sMA.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 179 | sMA +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "MA"; |
| 180 | sMA +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 181 | break; |
| 182 | case markTextcxx . . $ markText.: |
| 183 | case markNumbercxx . . $ markNumber.: |
| 184 | if (sLB.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 185 | sLB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "LB"; |
| 186 | sLB +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j); |
| 187 | sLB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). ":"; |
| 188 | txt =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). getMarkTextcxx . . $ Matrix#getMarkText(ff5dcb9213a676d0).(i+1, j+1); |
| 189 | if (txt.isNullcxx . . $ QString#isNull(50ce9a9e25b4a850).() || txt.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 190 | sLB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "?"; // Whoops |
| 191 | else |
| 192 | sLB +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). txt; |
| 193 | sLB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "]"; |
| 194 | break; |
| 195 | case markTerrBlackcxx . . $ markTerrBlack.: |
| 196 | if (sTB.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 197 | { |
| 198 | sTB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\nTB"; |
| 199 | colb = 0; |
| 200 | } |
| 201 | sTB +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 202 | if (++colb % 15 == 0) |
| 203 | sTB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\n "; |
| 204 | break; |
| 205 | case markTerrWhitecxx . . $ markTerrWhite.: |
| 206 | if (sTW.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 207 | { |
| 208 | sTW +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\nTW"; |
| 209 | colw = 0; |
| 210 | } |
| 211 | sTW +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 212 | if (++colw % 15 == 0) |
| 213 | sTW +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\n "; |
| 214 | break; |
| 215 | default: continue; |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | return sSQ +cxx . . $ operator+(fab9b4f80031f353). sCR +cxx . . $ operator+(fab9b4f80031f353). sTR +cxx . . $ operator+(fab9b4f80031f353). sMA +cxx . . $ operator+(fab9b4f80031f353). sLB +cxx . . $ operator+(fab9b4f80031f353). sTB +cxx . . $ operator+(fab9b4f80031f353). sTW; |
| 221 | } |
| 222 | |
| 223 | /* |
| 224 | * returns a string representing the edited stones in the matrix, in SGF format |
| 225 | */ |
| 226 | const QStringcxx . . $ QString# Matrixcxx . . $ Matrix#::saveEditedMovescxx . . $ Matrix#saveEditedMoves(58a83039bbc051dc).(Matrixcxx . . $ Matrix# *parent) |
| 227 | { |
| 228 | QStringcxx . . $ QString# sAB=""cxx . . $ QString#QString(85c52e162fed56f9)., sAW=""cxx . . $ QString#QString(85c52e162fed56f9)., sAE=""cxx . . $ QString#QString(85c52e162fed56f9).; |
| 229 | int i, j; |
| 230 | int z; |
| 231 | for (i=0; i<sizecxx . . $ Matrix#size.; i++) |
| 232 | { |
| 233 | for (j=0; j<sizecxx . . $ Matrix#size.; j++) |
| 234 | { |
| 235 | z = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(i + 1, j + 1); |
| 236 | if (z != 0) |
| 237 | z= 0; |
| 238 | if(!(matrixcxx . . $ Matrix#matrix.[internalCoordsToKeycxx . . $ Matrix#internalCoordsToKey(adc74905ab378dc7).(i,j)] & MX_STONEEDITcxx . . $ `src/game_tree/matrix.h:35:9`!)) |
| 239 | continue; |
| 240 | switch (getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(i + 1, j + 1)) |
| 241 | { |
| 242 | case stoneBlackcxx . . $ stoneBlack.: |
| 243 | if (parent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && |
| 244 | parent->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(i + 1, j + 1) == stoneBlackcxx . . $ stoneBlack.) |
| 245 | break; |
| 246 | if (sAB.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 247 | sAB +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "AB"; |
| 248 | sAB +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 249 | break; |
| 250 | |
| 251 | case stoneWhitecxx . . $ stoneWhite.: |
| 252 | if (parent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && |
| 253 | parent->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(i + 1, j + 1) == stoneWhitecxx . . $ stoneWhite.) |
| 254 | break; |
| 255 | if (sAW.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 256 | sAW +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "AW"; |
| 257 | sAW +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 258 | break; |
| 259 | |
| 260 | case stoneErasecxx . . $ stoneErase.: |
| 261 | if (parent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && |
| 262 | (parent->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(i + 1, j + 1) == stoneNonecxx . . $ stoneNone. || |
| 263 | parent->getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(i + 1, j + 1) == stoneErasecxx . . $ stoneErase.)) |
| 264 | break; |
| 265 | if (sAE.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 266 | sAE +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "AE"; |
| 267 | sAE +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). "[" +cxx . . $ operator+(c75c3ae4eb9af1a8). coordsToStringcxx . . $ Matrix#coordsToString(ff5dcb9213a676d0).(i, j) +cxx . . $ operator+(3d22f08efddf8107). "]"; |
| 268 | break; |
| 269 | default: |
| 270 | case stoneNonecxx . . $ stoneNone.: |
| 271 | break; |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | return sAB +cxx . . $ operator+(fab9b4f80031f353). sAW +cxx . . $ operator+(fab9b4f80031f353). sAE; |
| 277 | } |
| 278 | |
| 279 | const QStringcxx . . $ QString# Matrixcxx . . $ Matrix#::printMecxx . . $ Matrix#printMe(32757fa23de63b9d).(ASCII_Importcxx . . $ ASCII_Import# *charset) |
| 280 | { |
| 281 | int i, j; |
| 282 | QStringcxx . . $ QString# strcxx . . $ QString#QString(ced63f7c635d850d).; |
| 283 | |
| 284 | str =cxx . . $ QString#`operator=`(d02845eef0c33901). "\n "; |
| 285 | for (i=0; i<sizecxx . . $ Matrix#size.; i++) |
| 286 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QStringcxx . . $ QString#QString(f2c90172ce699d92).(QCharcxx . . $ QChar#(static_cast<const char>('A' + (i<8?i:i+1)))) +cxx . . $ operator+(3d22f08efddf8107). " "; |
| 287 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\n +"; |
| 288 | for (i=0; i<sizecxx . . $ Matrix#size.-1; i++) |
| 289 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "--"; |
| 290 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "-+\n"; |
| 291 | |
| 292 | for (i=0; i<sizecxx . . $ Matrix#size.; i++) |
| 293 | { |
| 294 | if (sizecxx . . $ Matrix#size.-i < 10) str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; |
| 295 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(sizecxx . . $ Matrix#size.-i) +cxx . . $ operator+(3d22f08efddf8107). " |"; |
| 296 | for (j=0; j<sizecxx . . $ Matrix#size.; j++) |
| 297 | { |
| 298 | switch (getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(j + 1, i + 1)) |
| 299 | { |
| 300 | case stoneBlackcxx . . $ stoneBlack.: str +=cxx . . $ QString#`operator+=`(3a2ffbdf8ecc25e2). QCharcxx . . $ QChar#(charset->blackStonecxx . . $ ASCII_Import#blackStone.); str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; break; |
| 301 | case stoneWhitecxx . . $ stoneWhite.: str +=cxx . . $ QString#`operator+=`(3a2ffbdf8ecc25e2). QCharcxx . . $ QChar#(charset->whiteStonecxx . . $ ASCII_Import#whiteStone.); str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; break; |
| 302 | default: |
| 303 | // Check for starpoints |
| 304 | if (sizecxx . . $ Matrix#size. > 9) // 10x10 or larger |
| 305 | { |
| 306 | if ((i == 3 && j == 3) || |
| 307 | (i == sizecxx . . $ Matrix#size.-4 && j == 3) || |
| 308 | (i == 3 && j == sizecxx . . $ Matrix#size.-4) || |
| 309 | (i == sizecxx . . $ Matrix#size.-4 && j == sizecxx . . $ Matrix#size.-4) || |
| 310 | (i == (sizecxx . . $ Matrix#size.+1)/2 - 1 && j == 3) || |
| 311 | (i == (sizecxx . . $ Matrix#size.+1)/2 - 1 && j == sizecxx . . $ Matrix#size.-4) || |
| 312 | (i == 3 && j == (sizecxx . . $ Matrix#size.+1)/2 - 1) || |
| 313 | (i == sizecxx . . $ Matrix#size.-4 && j == (sizecxx . . $ Matrix#size.+1)/2 - 1) || |
| 314 | (i == (sizecxx . . $ Matrix#size.+1)/2 - 1 && j == (sizecxx . . $ Matrix#size.+1)/2 - 1)) |
| 315 | { |
| 316 | str +=cxx . . $ QString#`operator+=`(3a2ffbdf8ecc25e2). QCharcxx . . $ QChar#(charset->starPointcxx . . $ ASCII_Import#starPoint.); |
| 317 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; |
| 318 | break; |
| 319 | } |
| 320 | } |
| 321 | else // 9x9 or smaller |
| 322 | { |
| 323 | if ((i == 2 && j == 2) || |
| 324 | (i == 2 && j == sizecxx . . $ Matrix#size.-3) || |
| 325 | (i == sizecxx . . $ Matrix#size.-3 && j == 2) || |
| 326 | (i == sizecxx . . $ Matrix#size.-3 && j == sizecxx . . $ Matrix#size.-3)) |
| 327 | { |
| 328 | str +=cxx . . $ QString#`operator+=`(3a2ffbdf8ecc25e2). QCharcxx . . $ QChar#(charset->starPointcxx . . $ ASCII_Import#starPoint.); |
| 329 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; |
| 330 | break; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | str +=cxx . . $ QString#`operator+=`(3a2ffbdf8ecc25e2). QCharcxx . . $ QChar#(charset->emptyPointcxx . . $ ASCII_Import#emptyPoint.); |
| 335 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; |
| 336 | break; |
| 337 | } |
| 338 | } |
| 339 | str =cxx . . $ QString#`operator=`(4f35bf974e7f8568). str.leftcxx . . $ QString#left(3f3c3d0e9c0eb37f).(str.lengthcxx . . $ QString#length(455f465bc33b4cdf).()-1); |
| 340 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "| "; |
| 341 | if (sizecxx . . $ Matrix#size.-i < 10) str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " "; |
| 342 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(sizecxx . . $ Matrix#size.-i) +cxx . . $ operator+(3d22f08efddf8107). "\n"; |
| 343 | } |
| 344 | |
| 345 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " +"; |
| 346 | for (i=0; i<sizecxx . . $ Matrix#size.-1; i++) |
| 347 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "--"; |
| 348 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "-+\n "; |
| 349 | for (i=0; i<sizecxx . . $ Matrix#size.; i++) |
| 350 | str +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QStringcxx . . $ QString#QString(f2c90172ce699d92).(QCharcxx . . $ QChar#(static_cast<const char>('A' + (i<8?i:i+1)))) +cxx . . $ operator+(3d22f08efddf8107). " "; |
| 351 | str +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "\n"; |
| 352 | |
| 353 | return strcxx . . $ QString#QString(28715ad661ad3cec).; |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * checks wether the positions x,y holds a stone 'color'. |
| 358 | * if yes, appends the stone and returns the group |
| 359 | */ |
| 360 | void Matrixcxx . . $ Matrix#::checkNeighbourcxx . . $ Matrix#checkNeighbour(1d8d88c027dffa2).(int key, StoneColorcxx . . $ StoneColor# color, Groupcxx . . $ Group# *group, stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> *libertyList) const |
| 361 | { |
| 362 | StoneColorcxx . . $ StoneColor# c = getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(key); |
| 363 | if(c != color) |
| 364 | { |
| 365 | if((libertyList) && (c == stoneNonecxx . . $ stoneNone.) |
| 366 | && (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(libertyList->begincxx . . $ std/vector#begin(55a6de06420d4903).(), libertyList->endcxx . . $ std/vector#end(55a6de06420d4903).(), key) ==cxx . . $ __gnu_cxx/`operator==`(30ee64f2df4eef8b). libertyList->endcxx . . $ std/vector#end(55a6de06420d4903).())) |
| 367 | { |
| 368 | libertyList->push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(key); |
| 369 | group->libertiescxx . . $ Group#liberties.++; |
| 370 | } |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | if (!(group->containscxx . . $ QList#contains(8877ebe272b9620d).(key))) |
| 375 | group->appendcxx . . $ QList#append(77d9f17553126ecb).(key); |
| 376 | } |
| 377 | |
| 378 | /* Counts and returns the number of liberties of a group. |
| 379 | * What does not count as a liberty is determined by "mask". |
| 380 | * By default "mask" is set to black and white stones, |
| 381 | * so any unoocupied point counts as a liberty. |
| 382 | * One can put opponent's territory into mask to exclude dame points |
| 383 | * from liberties. This is useful for detecting false eyes. */ |
| 384 | int Matrixcxx . . $ Matrix#::countLibertiescxx . . $ Matrix#countLiberties(52b9dbe09fcca159).(Groupcxx . . $ Group# *group, unsigned short mask) |
| 385 | { |
| 386 | QVectorcxx . . $ QVector#<int> libCountedcxx . . $ QVector#QVector(ced63f7c635d850d).; |
| 387 | |
| 388 | // Walk through the horizontal and vertial directions, counting the |
| 389 | // liberties of this group. |
| 390 | for (int i=0; i<group->countcxx . . $ QList#count(455f465bc33b4cdf).(); i++) |
| 391 | { |
| 392 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> neighbors = getNeighborscxx . . $ Matrix#getNeighbors(bf04f17e6fc0658e).(group->atcxx . . $ QList#at(e2681f9bb6b2f357).(i)); |
| 393 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>::iteratorcxx . . $ std/vector#iterator# it_neighborcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 394 | for (it_neighbor =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(3e724b8277136f56). neighbors.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it_neighbor <cxx . . $ __gnu_cxx/`operator<`(30ee64f2df4eef8b). neighbors.endcxx . . $ std/vector#end(55a6de06420d4903).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(1613faa01bc3d014).it_neighbor) |
| 395 | { |
| 396 | if ( !(matrixcxx . . $ Matrix#matrix.[*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor] & mask) && |
| 397 | !libCounted.containscxx . . $ QVector#contains(8877ebe272b9620d).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor)) |
| 398 | { |
| 399 | libCounted.appendcxx . . $ QVector#append(77d9f17553126ecb).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor); |
| 400 | } |
| 401 | |
| 402 | } |
| 403 | } |
| 404 | return libCounted.sizecxx . . $ QVector#size(455f465bc33b4cdf).(); |
| 405 | } |
| 406 | |
| 407 | /* |
| 408 | * Returns the group (QList) of matrix stones connected with the stone "key" |
| 409 | */ |
| 410 | Groupcxx . . $ Group#* Matrixcxx . . $ Matrix#::assembleGroupcxx . . $ Matrix#assembleGroup(19a7d4c00f8ff9f6).(int key, StoneColorcxx . . $ StoneColor# c) const |
| 411 | { |
| 412 | Groupcxx . . $ Group# *group = new Groupcxx . . $ Group#Group(42096433316d3db3).(c); |
| 413 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(group); |
| 414 | group->appendcxx . . $ QList#append(77d9f17553126ecb).(key); |
| 415 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> libertyListcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 416 | int mark = 0; |
| 417 | |
| 418 | // Walk through the horizontal and vertical directions and assemble the |
| 419 | // attached stones to this group. |
| 420 | while (mark < group->countcxx . . $ QList#count(455f465bc33b4cdf).()) |
| 421 | { |
| 422 | if (getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(group->atcxx . . $ QList#at(e2681f9bb6b2f357).(mark)) != stoneNonecxx . . $ stoneNone. ) //FIXME how can this be stoneNone? |
| 423 | { |
| 424 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> neighbors = getNeighborscxx . . $ Matrix#getNeighbors(bf04f17e6fc0658e).(group->atcxx . . $ QList#at(e2681f9bb6b2f357).(mark)); |
| 425 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>::iteratorcxx . . $ std/vector#iterator# it_neighborcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 426 | for (it_neighbor =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(3e724b8277136f56). neighbors.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it_neighbor <cxx . . $ __gnu_cxx/`operator<`(30ee64f2df4eef8b). neighbors.endcxx . . $ std/vector#end(55a6de06420d4903).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(1613faa01bc3d014).it_neighbor) |
| 427 | checkNeighbourcxx . . $ Matrix#checkNeighbour(1d8d88c027dffa2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor,c,group, &libertyList); |
| 428 | } |
| 429 | mark ++; |
| 430 | } |
| 431 | |
| 432 | return group; |
| 433 | } |
| 434 | |
| 435 | /* This puts groups that the stone touches into "visited" and counts the |
| 436 | * number of captured stones (positive if enemy stones are captured, |
| 437 | * negative for suicide). This number can be used to check if the |
| 438 | * move is legal before playing it. |
| 439 | * This function does not alter the matrix */ |
| 440 | int Matrixcxx . . $ Matrix#::checkStoneCapturescxx . . $ Matrix#checkStoneCaptures(3f4db0380f904985).(StoneColorcxx . . $ StoneColor# ourColor, int x, int y, stdcxx . . $ std/::vectorcxx . . $ std/vector#<Groupcxx . . $ Group# *> &visited) const |
| 441 | { |
| 442 | StoneColorcxx . . $ StoneColor# theirColor = (ourColor == stoneWhitecxx . . $ stoneWhite. ? stoneBlackcxx . . $ stoneBlack. : stoneWhitecxx . . $ stoneWhite.); |
| 443 | StoneColorcxx . . $ StoneColor# c; |
| 444 | Groupcxx . . $ Group# * g = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 445 | bool emptyNeighbor = false; |
| 446 | |
| 447 | // Find adjacent groups and put them into "visited" |
| 448 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> neighbors = getNeighborscxx . . $ Matrix#getNeighbors(bf04f17e6fc0658e).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)); |
| 449 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>::iteratorcxx . . $ std/vector#iterator# it_neighborcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 450 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Group *>::iteratorcxx . . $ std/vector#iterator# it_visitedcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 451 | for (it_neighbor =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(3e724b8277136f56). neighbors.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it_neighbor <cxx . . $ __gnu_cxx/`operator<`(30ee64f2df4eef8b). neighbors.endcxx . . $ std/vector#end(55a6de06420d4903).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(1613faa01bc3d014).it_neighbor) |
| 452 | { |
| 453 | c = getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor); |
| 454 | if ((c == stoneBlackcxx . . $ stoneBlack.) || (c == stoneWhitecxx . . $ stoneWhite.)) |
| 455 | { |
| 456 | g = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 457 | 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) |
| 458 | { |
| 459 | if ((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->containscxx . . $ QList#contains(8877ebe272b9620d).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor)) |
| 460 | { |
| 461 | g = *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited; |
| 462 | break; |
| 463 | } |
| 464 | } |
| 465 | if (g == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 466 | { |
| 467 | g = assembleGroupcxx . . $ Matrix#assembleGroup(19a7d4c00f8ff9f6).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor, c); |
| 468 | visited.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(g); |
| 469 | } |
| 470 | } else |
| 471 | emptyNeighbor = true; |
| 472 | } |
| 473 | |
| 474 | // Count the number of captured stones |
| 475 | int captures = 0; |
| 476 | // Check if some enemy groups are captured |
| 477 | 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) |
| 478 | { |
| 479 | if (((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->ccxx . . $ Group#c. == theirColor) && ((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->libertiescxx . . $ Group#liberties. == 1)) |
| 480 | captures += (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->sizecxx . . $ QList#size(ea6fe5115c70a13f).(); |
| 481 | } |
| 482 | // If enemy captured, return number of captures |
| 483 | if (captures > 0) |
| 484 | return captures; |
| 485 | // If no enemies captured, proceed |
| 486 | // If some neighboring square is empty, this is not a suicide |
| 487 | if (emptyNeighbor) |
| 488 | return 0; |
| 489 | // Count the number of stones in our adjacent groups |
| 490 | emptyNeighbor = false; |
| 491 | 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) |
| 492 | { |
| 493 | if ((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->ccxx . . $ Group#c. == ourColor) |
| 494 | { |
| 495 | captures -= (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->sizecxx . . $ QList#size(ea6fe5115c70a13f).(); |
| 496 | if ((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->libertiescxx . . $ Group#liberties. > 1) |
| 497 | emptyNeighbor = true; |
| 498 | } |
| 499 | } |
| 500 | // If some group has >1 liberty, this is not a suicide |
| 501 | if (emptyNeighbor) |
| 502 | return 0; |
| 503 | // Else this is a suicide, return the (negative) number of dying stones |
| 504 | return captures-1; |
| 505 | } |
| 506 | |
| 507 | /* This function executes a move without checking its validity. |
| 508 | * This function returns the number of captured stones. |
| 509 | * If the return value is negative, this means that the requested move |
| 510 | * was a suicide. */ |
| 511 | int Matrixcxx . . $ Matrix#::makeMovecxx . . $ Matrix#makeMove(bed22547599c466d).(int x, int y, StoneColorcxx . . $ StoneColor# c) |
| 512 | { |
| 513 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Groupcxx . . $ Group# *> visitedcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 514 | int capturedStones = checkStoneCapturescxx . . $ Matrix#checkStoneCaptures(3f4db0380f904985).(c, x, y, visited); |
| 515 | |
| 516 | if (capturedStones >= 0) |
| 517 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(x, y, c); |
| 518 | |
| 519 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Group *>::iteratorcxx . . $ std/vector#iterator# it_visitedcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 520 | 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) |
| 521 | { |
| 522 | if (((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->ccxx . . $ Group#c. != c) && ((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->libertiescxx . . $ Group#liberties. == 1)) // Enemy group with one liberty |
| 523 | { |
| 524 | removeGroupcxx . . $ Matrix#removeGroup(91c185f55c453815).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)); |
| 525 | } else if (((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)->ccxx . . $ Group#c. == c) && (capturedStones < 0)) // suicide |
| 526 | { |
| 527 | removeGroupcxx . . $ Matrix#removeGroup(91c185f55c453815).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited)); |
| 528 | } else |
| 529 | { |
| 530 | delete (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_visited); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | // Add Ko mark |
| 535 | if (capturedStones == 1) |
| 536 | { |
| 537 | int koStoneX = -1, koStoneY = -1; |
| 538 | StoneColorcxx . . $ StoneColor# opp = (c == stoneBlackcxx . . $ stoneBlack. ? stoneWhitecxx . . $ stoneWhite. : stoneBlackcxx . . $ stoneBlack.); |
| 539 | StoneColorcxx . . $ StoneColor# testcolor; |
| 540 | int sides = 4; |
| 541 | if(x < sizecxx . . $ Matrix#size.) |
| 542 | { |
| 543 | testcolor = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x + 1, y); |
| 544 | if(testcolor == opp) |
| 545 | sides--; |
| 546 | else if(testcolor == stoneNonecxx . . $ stoneNone.) |
| 547 | { |
| 548 | koStoneX = x + 1; |
| 549 | koStoneY = y; |
| 550 | } |
| 551 | } |
| 552 | else |
| 553 | sides--; |
| 554 | |
| 555 | if(x > 1) |
| 556 | { |
| 557 | testcolor = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x - 1, y); |
| 558 | if(testcolor == opp) |
| 559 | sides--; |
| 560 | else if(testcolor == stoneNonecxx . . $ stoneNone.) |
| 561 | { |
| 562 | koStoneX = x - 1; |
| 563 | koStoneY = y; |
| 564 | } |
| 565 | } |
| 566 | else |
| 567 | sides--; |
| 568 | if(y < sizecxx . . $ Matrix#size.) |
| 569 | { |
| 570 | testcolor = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x, y + 1); |
| 571 | if(testcolor == opp) |
| 572 | sides--; |
| 573 | else if(testcolor == stoneNonecxx . . $ stoneNone.) |
| 574 | { |
| 575 | koStoneX = x; |
| 576 | koStoneY = y + 1; |
| 577 | } |
| 578 | } |
| 579 | else |
| 580 | sides--; |
| 581 | |
| 582 | if(y > 1) |
| 583 | { |
| 584 | testcolor = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x, y - 1); |
| 585 | if(testcolor == opp) |
| 586 | sides--; |
| 587 | else if(testcolor == stoneNonecxx . . $ stoneNone.) |
| 588 | { |
| 589 | koStoneX = x; |
| 590 | koStoneY = y - 1; |
| 591 | } |
| 592 | } |
| 593 | else |
| 594 | sides--; |
| 595 | |
| 596 | if(sides == 1) |
| 597 | insertMarkcxx . . $ Matrix#insertMark(2fb52c50f1893bf2).(koStoneX, koStoneY, markKoMarkercxx . . $ markKoMarker.); |
| 598 | } |
| 599 | |
| 600 | return capturedStones; |
| 601 | } |
| 602 | |
| 603 | bool Matrixcxx . . $ Matrix#::addHandicapStonescxx . . $ Matrix#addHandicapStones(83c267b20bac841a).(int handicap) |
| 604 | { |
| 605 | if (sizecxx . . $ Matrix#size. > 25 || sizecxx . . $ Matrix#size. < 7) |
| 606 | { |
| 607 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("Matrix::addHandicapStones() : Can't set handicap for this board size"); |
| 608 | return false; |
| 609 | } |
| 610 | const int edge_dist = (sizecxx . . $ Matrix#size. > 12 ? 4 : 3); |
| 611 | const int low = edge_dist; |
| 612 | const int middle = (sizecxx . . $ Matrix#size. + 1) / 2; |
| 613 | const int high = sizecxx . . $ Matrix#size. + 1 - edge_dist; |
| 614 | // extra: |
| 615 | if (sizecxx . . $ Matrix#size. == 19 && handicap > 9) |
| 616 | switch (handicap) |
| 617 | { |
| 618 | case 13: // Hehe, this is nuts... :) |
| 619 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(17, 17, stoneBlackcxx . . $ stoneBlack., true); |
| 620 | case 12: |
| 621 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(3, 3, stoneBlackcxx . . $ stoneBlack., true); |
| 622 | case 11: |
| 623 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(3, 17, stoneBlackcxx . . $ stoneBlack., true); |
| 624 | case 10: |
| 625 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(17, 3, stoneBlackcxx . . $ stoneBlack., true); |
| 626 | |
| 627 | default: |
| 628 | handicap = 9; |
| 629 | break; |
| 630 | } |
| 631 | |
| 632 | switch (sizecxx . . $ Matrix#size. % 2) |
| 633 | { |
| 634 | // odd board size |
| 635 | case 1: |
| 636 | switch (handicap) |
| 637 | { |
| 638 | case 9: |
| 639 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(middle, middle, stoneBlackcxx . . $ stoneBlack., true); |
| 640 | case 8: |
| 641 | case 7: |
| 642 | if (handicap >= 8) |
| 643 | { |
| 644 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(middle, low, stoneBlackcxx . . $ stoneBlack., true); |
| 645 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(middle, high, stoneBlackcxx . . $ stoneBlack., true); |
| 646 | } |
| 647 | else |
| 648 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(middle, middle, stoneBlackcxx . . $ stoneBlack., true); |
| 649 | case 6: |
| 650 | case 5: |
| 651 | if (handicap >= 6) |
| 652 | { |
| 653 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(low, middle, stoneBlackcxx . . $ stoneBlack., true); |
| 654 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(high, middle, stoneBlackcxx . . $ stoneBlack., true); |
| 655 | } |
| 656 | else |
| 657 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(middle, middle, stoneBlackcxx . . $ stoneBlack., true); |
| 658 | case 4: |
| 659 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(high, high, stoneBlackcxx . . $ stoneBlack., true); |
| 660 | case 3: |
| 661 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(low, low, stoneBlackcxx . . $ stoneBlack., true); |
| 662 | case 2: |
| 663 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(high, low, stoneBlackcxx . . $ stoneBlack., true); |
| 664 | case 1: // Handicap 1? Whatever floats your boat. |
| 665 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(low, high, stoneBlackcxx . . $ stoneBlack., true); |
| 666 | break; |
| 667 | |
| 668 | default: |
| 669 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** BoardHandler::setHandicap() - Invalid handicap given: %d", handicap); |
| 670 | } |
| 671 | break; |
| 672 | |
| 673 | // even board size |
| 674 | case 0: |
| 675 | switch (handicap) |
| 676 | { |
| 677 | case 4: |
| 678 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(high, high, stoneBlackcxx . . $ stoneBlack.); |
| 679 | case 3: |
| 680 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(low, low, stoneBlackcxx . . $ stoneBlack.); |
| 681 | case 2: |
| 682 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(high, low, stoneBlackcxx . . $ stoneBlack.); |
| 683 | case 1: // Handicap 1? Whatever floats your boat. |
| 684 | insertStonecxx . . $ Matrix#insertStone(adfa9924dba61c7b).(low, high, stoneBlackcxx . . $ stoneBlack.); |
| 685 | break; |
| 686 | |
| 687 | default: |
| 688 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** Matrix::addHandicapStones() - Invalid handicap given: %d", handicap); |
| 689 | } |
| 690 | break; |
| 691 | |
| 692 | default: |
| 693 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** Matrix::addHandicapStones() - can't set handicap for this board size"); |
| 694 | } |
| 695 | return true; |
| 696 | } |
| 697 | |
| 698 | /* Note that checkStoneWithGroups would be called before this meaning that |
| 699 | * their could be no adjacent stones not in groups */ |
| 700 | void Matrixcxx . . $ Matrix#::removeGroupcxx . . $ Matrix#removeGroup(91c185f55c453815).(Groupcxx . . $ Group# * g) |
| 701 | { |
| 702 | /* For every stone in g we go through the neighboring groups. |
| 703 | * If the neighboring group is distinct from g, then it has different color. |
| 704 | * Every such group gets its number of liberties increased by 1. |
| 705 | * We take care not to count such groups multiple times. */ |
| 706 | for(int n = 0; n < g->countcxx . . $ QList#count(455f465bc33b4cdf).(); ++n) |
| 707 | { |
| 708 | insertStonecxx . . $ Matrix#insertStone(86392494ac0cc61f).(g->atcxx . . $ QList#at(e2681f9bb6b2f357).(n), stoneNonecxx . . $ stoneNone.); |
| 709 | } |
| 710 | delete g; |
| 711 | } |
| 712 | |
| 713 | /* This is kind of ugly but I'm trying to use the existing matrix |
| 714 | * code for something weird |
| 715 | * Could there be a potential miscalc if called on empty vertex? |
| 716 | * Would it be*/ |
| 717 | Groupcxx . . $ Group#* Matrixcxx . . $ Matrix#::assembleAreaGroupscxx . . $ Matrix#assembleAreaGroups(93920e3289793f04).(int key, StoneColorcxx . . $ StoneColor# c) |
| 718 | { |
| 719 | Groupcxx . . $ Group# *group = new Groupcxx . . $ Group#Group(42096433316d3db3).(c); |
| 720 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(group); |
| 721 | StoneColorcxx . . $ StoneColor# oppColor = (c == stoneWhitecxx . . $ stoneWhite. ? stoneBlackcxx . . $ stoneBlack. : stoneWhitecxx . . $ stoneWhite.); |
| 722 | |
| 723 | group->appendcxx . . $ QList#append(77d9f17553126ecb).(key); |
| 724 | |
| 725 | int mark = 0; |
| 726 | // Walk through the horizontal and vertical directions and assemble the |
| 727 | // attached stones to this group. |
| 728 | while (mark < group->countcxx . . $ QList#count(455f465bc33b4cdf).()) |
| 729 | { |
| 730 | if (getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(group->atcxx . . $ QList#at(e2681f9bb6b2f357).(mark)) != oppColor ) |
| 731 | { |
| 732 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> neighbors = getNeighborscxx . . $ Matrix#getNeighbors(bf04f17e6fc0658e).(group->atcxx . . $ QList#at(e2681f9bb6b2f357).(mark)); |
| 733 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>::iteratorcxx . . $ std/vector#iterator# it_neighborcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 734 | for (it_neighbor =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(3e724b8277136f56). neighbors.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it_neighbor <cxx . . $ __gnu_cxx/`operator<`(30ee64f2df4eef8b). neighbors.endcxx . . $ std/vector#end(55a6de06420d4903).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(1613faa01bc3d014).it_neighbor) |
| 735 | { |
| 736 | checkNeighbourcxx . . $ Matrix#checkNeighbour(1d8d88c027dffa2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor,c,group); |
| 737 | checkNeighbourcxx . . $ Matrix#checkNeighbour(1d8d88c027dffa2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor,stoneNonecxx . . $ stoneNone.,group); |
| 738 | } |
| 739 | } |
| 740 | mark ++; |
| 741 | } |
| 742 | |
| 743 | return group; |
| 744 | } |
| 745 | |
| 746 | /* |
| 747 | * This function marks all the stones of a group as dead (or alive if they were dead) |
| 748 | */ |
| 749 | void Matrixcxx . . $ Matrix#::toggleGroupAtcxx . . $ Matrix#toggleGroupAt(3e454b8ccf442868).( int x, int y) |
| 750 | { |
| 751 | StoneColorcxx . . $ StoneColor# col = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x, y); |
| 752 | |
| 753 | if ( col != stoneWhitecxx . . $ stoneWhite. && col != stoneBlackcxx . . $ stoneBlack. ) |
| 754 | return ; |
| 755 | |
| 756 | Groupcxx . . $ Group# *g = assembleGroupcxx . . $ Matrix#assembleGroup(19a7d4c00f8ff9f6).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y),col); //FIXME use the view |
| 757 | |
| 758 | for (int i=0; i<g->countcxx . . $ QList#count(455f465bc33b4cdf).(); i++) |
| 759 | toggleStoneAtcxx . . $ Matrix#toggleStoneAt(d4f767463ce0a6b3).(g->atcxx . . $ QList#at(e2681f9bb6b2f357).(i)); |
| 760 | } |
| 761 | |
| 762 | /* These are all kind of redundant, some aren't used, etc.. |
| 763 | * the other thing that bothers me is that the stone.cpp class |
| 764 | * should probably hold "dirty" and then we've considered before |
| 765 | * that matrix could be removed for something that takes up |
| 766 | * less space, but if this works for now, that's fine. FIXME */ |
| 767 | |
| 768 | void Matrixcxx . . $ Matrix#::toggleStoneAtcxx . . $ Matrix#toggleStoneAt(d4f767463ce0a6b3).(int key) |
| 769 | { |
| 770 | matrixcxx . . $ Matrix#matrix.[key] ^= MX_STONEDEADcxx . . $ `src/game_tree/matrix.h:34:9`!; |
| 771 | } |
| 772 | |
| 773 | void Matrixcxx . . $ Matrix#::toggleStoneAtcxx . . $ Matrix#toggleStoneAt(3e454b8ccf442868).(int x, int y) |
| 774 | { |
| 775 | toggleStoneAtcxx . . $ Matrix#toggleStoneAt(d4f767463ce0a6b3).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y)); |
| 776 | } |
| 777 | |
| 778 | |
| 779 | void Matrixcxx . . $ Matrix#::markStoneDeadcxx . . $ Matrix#markStoneDead(3e454b8ccf442868).(int x, int y) |
| 780 | { |
| 781 | if(isStoneDeadcxx . . $ Matrix#isStoneDead(cf9ef193275fa6d8).(x, y)) |
| 782 | return; |
| 783 | toggleStoneAtcxx . . $ Matrix#toggleStoneAt(3e454b8ccf442868).(x, y); |
| 784 | } |
| 785 | |
| 786 | void Matrixcxx . . $ Matrix#::markGroupDeadcxx . . $ Matrix#markGroupDead(3e454b8ccf442868).(int x, int y) |
| 787 | { |
| 788 | if(isStoneDeadcxx . . $ Matrix#isStoneDead(cf9ef193275fa6d8).(x, y)) |
| 789 | return; |
| 790 | toggleGroupAtcxx . . $ Matrix#toggleGroupAt(3e454b8ccf442868).(x, y); |
| 791 | } |
| 792 | |
| 793 | void Matrixcxx . . $ Matrix#::markGroupAlivecxx . . $ Matrix#markGroupAlive(3e454b8ccf442868).(int x, int y) |
| 794 | { |
| 795 | if(!isStoneDeadcxx . . $ Matrix#isStoneDead(cf9ef193275fa6d8).(x, y)) |
| 796 | return; |
| 797 | toggleGroupAtcxx . . $ Matrix#toggleGroupAt(3e454b8ccf442868).(x, y); |
| 798 | } |
| 799 | |
| 800 | /* Any stones connected to this xy stone by empty |
| 801 | * vertices are to be marked dead */ |
| 802 | void Matrixcxx . . $ Matrix#::toggleAreaAtcxx . . $ Matrix#toggleAreaAt(3e454b8ccf442868).( int x, int y) |
| 803 | { |
| 804 | StoneColorcxx . . $ StoneColor# col = getStoneAtcxx . . $ Matrix#getStoneAt(876dc10d7c60d8).(x, y); |
| 805 | |
| 806 | if ( col != stoneWhitecxx . . $ stoneWhite. && col != stoneBlackcxx . . $ stoneBlack. ) |
| 807 | return ; |
| 808 | |
| 809 | Groupcxx . . $ Group# *g = assembleAreaGroupscxx . . $ Matrix#assembleAreaGroups(93920e3289793f04).(coordsToKeycxx . . $ Matrix#coordsToKey(adc74905ab378dc7).(x,y),col); |
| 810 | |
| 811 | for (int i=0; i<g->countcxx . . $ QList#count(455f465bc33b4cdf).(); i++) |
| 812 | toggleStoneAtcxx . . $ Matrix#toggleStoneAt(d4f767463ce0a6b3).(g->atcxx . . $ QList#at(e2681f9bb6b2f357).(i)); |
| 813 | |
| 814 | delete g; |
| 815 | } |
| 816 | |
| 817 | void Matrixcxx . . $ Matrix#::markAreaDeadcxx . . $ Matrix#markAreaDead(3e454b8ccf442868).(int x, int y) |
| 818 | { |
| 819 | if(isStoneDeadcxx . . $ Matrix#isStoneDead(cf9ef193275fa6d8).(x, y)) |
| 820 | return; |
| 821 | toggleAreaAtcxx . . $ Matrix#toggleAreaAt(3e454b8ccf442868).(x, y); |
| 822 | } |
| 823 | |
| 824 | void Matrixcxx . . $ Matrix#::markAreaAlivecxx . . $ Matrix#markAreaAlive(3e454b8ccf442868).(int x, int y) |
| 825 | { |
| 826 | if(!isStoneDeadcxx . . $ Matrix#isStoneDead(cf9ef193275fa6d8).(x, y)) |
| 827 | return; |
| 828 | toggleAreaAtcxx . . $ Matrix#toggleAreaAt(3e454b8ccf442868).(x, y); |
| 829 | } |
| 830 | |
| 831 | void Matrixcxx . . $ Matrix#::floodTerritorycxx . . $ Matrix#floodTerritory(cde69bbbe2f15639).(unsigned short mark, int key) |
| 832 | { |
| 833 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> neighbors = getNeighborscxx . . $ Matrix#getNeighbors(bf04f17e6fc0658e).(key); |
| 834 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>::iteratorcxx . . $ std/vector#iterator# it_neighborcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ced63f7c635d850d).; |
| 835 | for (it_neighbor =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(3e724b8277136f56). neighbors.begincxx . . $ std/vector#begin(55a6de06420d4903).(); it_neighbor <cxx . . $ __gnu_cxx/`operator<`(30ee64f2df4eef8b). neighbors.endcxx . . $ std/vector#end(55a6de06420d4903).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(1613faa01bc3d014).it_neighbor) |
| 836 | { |
| 837 | // If the neighbor point does not hold a live stone and has not been flooded yet |
| 838 | if (((getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor) == stoneNonecxx . . $ stoneNone.) || (matrixcxx . . $ Matrix#matrix.[*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor] & MX_STONEDEADcxx . . $ `src/game_tree/matrix.h:34:9`!)) && (!(matrixcxx . . $ Matrix#matrix.[*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor] & mark))) |
| 839 | { |
| 840 | matrixcxx . . $ Matrix#matrix.[*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor] |= mark; |
| 841 | floodTerritorycxx . . $ Matrix#floodTerritory(cde69bbbe2f15639).(mark, *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).it_neighbor); |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | void Matrixcxx . . $ Matrix#::markTerritorycxx . . $ Matrix#markTerritory(49f6e7a06ebc5aa8).() |
| 847 | { |
| 848 | clearTerritoryMarkscxx . . $ Matrix#clearTerritoryMarks(49f6e7a06ebc5aa8).(); |
| 849 | |
| 850 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; ++i) |
| 851 | { |
| 852 | // If there is a live stone at i |
| 853 | if ((getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(i) != stoneNonecxx . . $ stoneNone.) && !(matrixcxx . . $ Matrix#matrix.[i] & MX_STONEDEADcxx . . $ `src/game_tree/matrix.h:34:9`!)) |
| 854 | // flood surrounding territory with its color |
| 855 | floodTerritorycxx . . $ Matrix#floodTerritory(cde69bbbe2f15639).(getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(i) == stoneBlackcxx . . $ stoneBlack. ? markTerrBlackcxx . . $ markTerrBlack. : markTerrWhitecxx . . $ markTerrWhite., i); |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | void Matrixcxx . . $ Matrix#::countcxx . . $ Matrix#count(a90a5d8ba88c22b1).(int &terrBlack, int &terrWhite, int &deadBlack, int &deadWhite) |
| 860 | { |
| 861 | terrWhite = 0; |
| 862 | terrBlack = 0; |
| 863 | deadBlack = 0; |
| 864 | deadWhite = 0; |
| 865 | // Count territory |
| 866 | for (int i=0; i<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.; ++i) |
| 867 | { |
| 868 | if (matrixcxx . . $ Matrix#matrix.[i] & markTerrWhitecxx . . $ markTerrWhite.) |
| 869 | { |
| 870 | if (!(matrixcxx . . $ Matrix#matrix.[i] & markTerrBlackcxx . . $ markTerrBlack.)) |
| 871 | ++terrWhite; |
| 872 | if (getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(i) == stoneBlackcxx . . $ stoneBlack.) |
| 873 | ++deadBlack; |
| 874 | } |
| 875 | if (matrixcxx . . $ Matrix#matrix.[i] & markTerrBlackcxx . . $ markTerrBlack.) |
| 876 | { |
| 877 | if (!(matrixcxx . . $ Matrix#matrix.[i] & markTerrWhitecxx . . $ markTerrWhite.)) |
| 878 | ++terrBlack; |
| 879 | if (getStoneAtcxx . . $ Matrix#getStoneAt(5e71495a53a18c05).(i) == stoneWhitecxx . . $ stoneWhite.) |
| 880 | ++deadWhite; |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | /* |
| 886 | * This function returns the first letter or number available in the letter marks |
| 887 | */ |
| 888 | QStringcxx . . $ QString# Matrixcxx . . $ Matrix#::getFirstTextAvailablecxx . . $ Matrix#getFirstTextAvailable(86e5271f0d39a332).(MarkTypecxx . . $ MarkType# t) |
| 889 | { |
| 890 | QStringcxx . . $ QString# markcxx . . $ QString#QString(ced63f7c635d850d).; |
| 891 | |
| 892 | switch (t) |
| 893 | { |
| 894 | case markTextcxx . . $ markText. : |
| 895 | for (int n = 0 ; n < 51 ; n++) |
| 896 | { |
| 897 | mark =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(f2c90172ce699d92).(QCharcxx . . $ QChar#(static_cast<const char>('A' + (n>=26 ? n+6 : n)))); |
| 898 | if (markTextscxx . . $ Matrix#markTexts..keycxx . . $ QHash#key(dd8c0696c30c0a31).(mark,-1) == -1) |
| 899 | break; |
| 900 | } |
| 901 | break; |
| 902 | case markNumbercxx . . $ markNumber. : |
| 903 | for (int n = 1 ; n < 400 ; n++) |
| 904 | { |
| 905 | mark =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(n); |
| 906 | if (markTextscxx . . $ Matrix#markTexts..keycxx . . $ QHash#key(dd8c0696c30c0a31).(mark,-1) == -1) |
| 907 | break; |
| 908 | } |
| 909 | break; |
| 910 | //should not happen |
| 911 | default: |
| 912 | break; |
| 913 | } |
| 914 | |
| 915 | return markcxx . . $ QString#QString(28715ad661ad3cec).; |
| 916 | } |
| 917 | |
| 918 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> Matrixcxx . . $ Matrix#::getNeighborscxx . . $ Matrix#getNeighbors(bf04f17e6fc0658e).(int key) const |
| 919 | { |
| 920 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> resultcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 921 | if (key >= sizecxx . . $ Matrix#size.) // north |
| 922 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(key-sizecxx . . $ Matrix#size.); |
| 923 | if ((key % sizecxx . . $ Matrix#size.) > 0) // west |
| 924 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(key-1); |
| 925 | if ((key % sizecxx . . $ Matrix#size.) < sizecxx . . $ Matrix#size.-1) // east |
| 926 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(key+1); |
| 927 | if ((key)<sizecxx . . $ Matrix#size.*sizecxx . . $ Matrix#size.-sizecxx . . $ Matrix#size.) // south |
| 928 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(key+sizecxx . . $ Matrix#size.); |
| 929 | return resultcxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 930 | } |