What should I do if I realize I made an illegal move in xiangqi?
These answers restate the rules implemented by our open-source engine, which follows the WXF laws and is regression-tested against the official 110-diagram repetition casebook. Where an answer refers to a specific position, that position lives on the linked reference page, where the build verifies it against the engine before publishing.
Direct answer
In casual or online play, it is simply undone: the move is retracted and a legal move played instead, with no penalty beyond a moment's embarrassment. In formal, arbitrated play, an illegal move is corrected under the event's specific rules, which typically involves the position being restored and a time penalty applied to the offending player.
Why illegal moves happen more than people expect
The most common cause by far is the flying general rule, moving a piece from between the two generals, exposing them to each other on a clear file. A close second is missing that a horse's leg or an elephant's eye is blocked. Both are easy to miss under time pressure even for experienced players.
Software prevents most of this anyway
A digital board simply will not let you complete an illegal move, and will usually show you why the move was refused, which is one of the more forgiving ways to learn these rules compared to a physical board and a strict arbiter.
Related questions
Does an illegal move ever stand if nobody notices?
In casual play, sometimes, if both players miss it and continue; in formal arbitrated play it is generally corrected once spotted, subject to the event's own time limits on doing so.
Is there a standard penalty for illegal moves in tournaments?
Time penalties are common; the specific amount and procedure depend on the organising federation's regulations.