| 107 | } |
| 108 | |
| 109 | int ChessBoard::getStoneCountAtLine(int row1, int col1, int row2, int col2) |
| 110 | { |
| 111 | int ret = 0; |
| 112 | if(row1 != row2 && col1 != col2) |
| 113 | return -1; |
| 114 | if(row1 == row2 && col1 == col2) |
| 115 | return -1; |
| 116 | |
| 117 | if(row1 == row2) |
| 118 | { |
| 119 | int min = col1 < col2 ? col1 : col2; |
| 120 | int max = col1 < col2 ? col2 : col1; |
| 121 | for(int col = min+1; col<max; ++col) |
| 122 | { |
| 123 | if(getStoneId(row1, col) != -1) |
| 124 | ++ret; |
| 125 | } |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | int min = row1 < row2 ? row1 : row2; |
| 130 | int max = row1 < row2 ? row2 : row1; |
| 131 | for(int row = min+1; row<max; ++row) |
| 132 | { |
| 133 | if(getStoneId(row, col1) != -1) |
| 134 | ++ret; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return ret; |
| 139 | } |
| 140 | |
| 141 | void ChessBoard::whoWin() //谁胜谁负 |
| 142 | { |
nothing calls this directly
no outgoing calls
no test coverage detected