public static bool WhiteHasMove(GridState[] board) { bool bMoveLeftForWhite = false; for (int i = 0; i < board.Count(); i++) { var piece = board[i]; if (piece == GridState.NULL || piece == GridState.EMPTY) continue; if ((piece == GridState.WHITEKING || piece == GridState.WHITEPAWN) && bMoveLeftForWhite == false) { bMoveLeftForWhite = FindMoveForWhite(piece, i, board); if (bMoveLeftForWhite) break; } } return bMoveLeftForWhite; }
public static bool BlackHasMove(GridState[] board) { bool bMoveLeftForBlack = false; for (int i = 0; i < board.Count(); i++) { var piece = board[i]; if (piece == GridState.NULL || piece == GridState.EMPTY) continue; if ((piece == GridState.BLACKPAWN || piece == GridState.BLACKKING) && bMoveLeftForBlack == false) { bMoveLeftForBlack = FindMoveForBlack(piece, i, board); if (bMoveLeftForBlack) break; } } return bMoveLeftForBlack; }
private int GetOverallScore(GridState[] bArray) { int CountB = 0; int CountW = 0; int CountBK = 0; int CountWK = 0; //var bMoveLeftForBlack = false; //var bMoveLeftForWhite = false; //for (int i = 0; i < BoardArray.Count(); i++) //{ // var piece = BoardArray[i]; // if (piece == GridState.BLACKPAWN || piece == GridState.BLACKKING) // { // bMoveLeftForBlack = moveLeftForBlack(piece, i); // if (bMoveLeftForBlack) // break; // } //} //for (int i = 0; i < BoardArray.Count(); i++) //{ // var piece = BoardArray[i]; // if (piece == GridState.WHITEKING || piece == GridState.WHITEPAWN) // { // bMoveLeftForWhite = moveLeftForWhite(piece, i); // if (bMoveLeftForWhite) // break; // } //} //if ((m_TurnForPlayerBlack && !bMoveLeftForBlack) || (!m_TurnForPlayerBlack && !bMoveLeftForWhite)) // GameOver = true; for (int i = 0; i < bArray.Count(); i++) { var piece = bArray[i]; if (piece == GridState.NULL || piece == GridState.EMPTY) continue; if (piece == GridState.BLACKPAWN) { CountB++; } if (piece == GridState.WHITEPAWN) { CountW++; } if (piece == GridState.BLACKKING) { CountB += 1; CountBK += 3; } if (piece == GridState.WHITEKING) { CountW += 1; CountWK += 3; } } if (m_TurnForPlayerBlack) { return (CountBK * 3) + ((CountBK - CountWK) * 5) + (CountB - CountW); } return -((CountWK * 3) + ((CountWK - CountWK) * 5) + (CountW - CountB)); }