In chess, a checkmate occurs when a players king is in check (threatened with capture) and has no possible escape. When a checkmate happens, the game ends immediately, and the player who delivered the checkmate wins. It is the ultimate goal of the game and can be achieved in various ways, such as using specific checkmating patterns or forcing the opponents king to the edge of the board. A checkmate can occur in as few as two moves on one side with all of the pieces still on the board, in a middlegame position, or after many moves with as few as three pieces in an endgame position.