Given a position, is there a way we can classify a it, such as if whether there is a pin, fork, or trap, or a mate a mate in 2 or 3? If it is possible, what would be a better approach, an algorithmic way or a machine learning/reinforcement learning? Or are there any other alternatives ways?
Yes. Let's break it down.
This is easily done by bitboard operations. I'm not aware of an independent package that can do that, but it's not hard to do it yourself. You just need to work out all the attackers (White and Black), where your pieces are, do some bitwise AND XOR operations. Please take a look at Stockfish's
mate a mate in 2 or 3
Easy! Just run Stockfish or even better a mate tactics solver such as
This is going to be very challenging if possible with our current technology. Chess engine doesn't really understand the moves, they assume best play. Computers doesn't understand human-imperfect-level dirty plays. You can work out some simple traps by passing the move to the other colour (e.g. lichess, chess.com etc), but you're not going to get perfect results.