예제 #1
0
func (b *TBoard) IsSquareColInCheck(sq square.TSquare, c piece.TColor) bool {
	ksq := b.Pos.GetKingPos(c)
	for _, pt := range ALL_PIECE_TYPES {
		test_piece := piece.FromTypeAndColor(pt, piece.InvColorOf(c))
		ptr := GetMoveTablePtr(ksq, test_piece)
		for !MoveTable[ptr].EndPiece {
			md := MoveTable[ptr]
			p := b.PieceAtSq(md.To)
			if p == test_piece {
				return true
			}
			if piece.ColorOf(p) != piece.NO_COLOR {
				ptr = md.NextVector
			} else {
				ptr++
			}
		}
	}
	return false
}
예제 #2
0
func InvTurnOfColor(c piece.TColor) TTurn {
	return TTurn(piece.InvColorOf(c))
}
예제 #3
0
func InvTurnOf(t TTurn) TTurn {
	return TTurn(piece.InvColorOf(piece.TColor(t)))
}
예제 #4
0
func (b *TBoard) IsOppInCheck() bool {
	return b.IsColInCheck(piece.InvColorOf(b.GetColorOfTurn()))
}