def rps_logic(p1_move, p2_move):
    """
    Execute logic of RPS Game.

    Rock < Paper < Scissors < Rock

    Args:
        p1_move (int): Encoded player1 move.
        p2_move (int): Encoded player2 move.

    Returns:
        0 if its a tie.
        1 if Player1 wins.
        2 if Player2 wins.

    """
    if p1_move == p2_move:
        # Same move, its a draw
        return 0
    if (p1_move - p2_move) == 1 or (p1_move - p2_move) == -2:
        # Player1 wins (Paper vs Rock or Scissors vs Paper or Rock vs Scissors)
        return 1

    # Player2 wins
    return 2