MCPcopy Create free account
hub / github.com/XMuli/ChineseChess / calcScore

Method calcScore

MachineGame.cpp:170–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170int MachineGame::calcScore()
171{
172 int blackScore = 0;
173 int redScore = 0;
174
175 for (int i = 0; i < 16; i++) {
176 if (m_ChessPieces[i].m_bDead) continue;
177 int type = m_ChessPieces[i].m_emType;
178 blackScore += chessScore[type];
179 if (m_difficulty >= AIDifficulty::Medium)
180 blackScore += getPositionScore(type, m_ChessPieces[i].m_nRow, m_ChessPieces[i].m_nCol, false);
181 }
182
183 for (int i = 16; i < 32; i++) {
184 if (m_ChessPieces[i].m_bDead) continue;
185 int type = m_ChessPieces[i].m_emType;
186 redScore += chessScore[type];
187 if (m_difficulty >= AIDifficulty::Medium)
188 redScore += getPositionScore(type, m_ChessPieces[i].m_nRow, m_ChessPieces[i].m_nCol, true);
189 }
190
191 // AI 执黑时返回 black-red,执红时返回 red-black
192 if (m_bAiIsRed)
193 return redScore - blackScore;
194 return blackScore - redScore;
195}
196
197int MachineGame::alphaBeta(int depth, int alpha, int beta, bool isMaximizing)
198{

Callers

nothing calls this directly

Calls 1

getPositionScoreFunction · 0.85

Tested by

no test coverage detected