So first, if there are only pawns and the king left, we can see if he is inside the square; if not, it means your pawn can promote. But if he is inside the square, it means a draw (if you only have one pawn left). What is the square? The square is the position where we look at the squares between the pawn’s position to the promotion square and the pawn’s position to the king’s square. The way to do it is that the pawn’s position to the promotion square must be closer than the pawn’s position to the king. So if the pawn is 4 squares away from promotion and the king is more than 4 squares away, you automatically win. But if the king is only 3 squares away from the pawn, it means the king can catch the pawn, which can result in a draw (especially if you only have one pawn left).