Keep your card or swap to beat a hidden one
You and an opponent each secretly receive a number drawn uniformly at random from to (the two draws are independent). You get to look at yours. You may keep it, or swap it for one fresh uniform draw from to (and you must keep the new one). The opponent never changes their number. Whoever ends with the higher number wins; ties count as a loss for you.
What is your optimal swap rule, and what is your resulting probability of winning?