- Illegal Chess is a chaotic Roblox chess game where unconventional moves and special abilities override standard rules.
- Illegal SAN occurs when a move string cannot be parsed or breaks the rules of the current board position.
- python-chess raises
IllegalMoveErrororInvalidMoveErrorwhen you push an illegal SAN string. - Core workflow: parse the SAN, validate it against the position, then handle the exception cleanly.
- Best practice: always wrap
board.parse_san()calls in try/except blocks for user-supplied input.
What Counts as an Illegal SAN Move?
In standard chess engines, a move written in Standard Algebraic Notation (SAN) is considered illegal when it either cannot be parsed at all, or when it describes a move that the rules do not allow from the current position. The python-chess library distinguishes several failure cases, and understanding them helps you debug move-validation code and, ironically, appreciate exactly what makes Illegal Chess on Roblox so chaotic — a game where "illegal" is the entire design philosophy.
| Error Type | Trigger Condition | Example Input |
|---|---|---|
InvalidMoveError | String is not valid SAN syntax at all | "Nf9", "banana", "xO-O" |
IllegalMoveError | Valid SAN, but not legal in the current position | "Qxd5" when no queen attacks d5 |
AmbiguousMoveError | SAN matches multiple pieces without a disambiguator | "Nf3" with knights on b1 and d2 both able to reach f3 |
InvalidMoveError means the notation itself is malformed. IllegalMoveError means the notation is fine, but the move breaks the rules of the position. AmbiguousMoveError means two or more identical pieces could make the move — add a file or rank disambiguator like Ngf3.
Catching Illegal Moves in python-chess
The most common source of confusion is trying to parse a SAN string directly into a move without validation. In python-chess, board.parse_san() returns a Move object only if the SAN is both syntactically valid and legal in the current position. Otherwise, it raises an exception that will crash your script unless handled.
| Method | Behavior on Illegal Input | Best Use Case |
|---|---|---|
board.parse_san(san) | Raises IllegalMoveError / InvalidMoveError | Strict validation |
board.parse_san(san, strict=False) on some forks | More lenient parsing | Legacy code |
chess.Move.from_uci(uci) | No legality check at all | Converting UCI strings |
board.san(move) | Converts move to SAN | Output formatting |
Set Up the Board
Import the library and create a chess.Board object. Every legality check runs against this position, so always reuse the same board instance across validation calls.
Wrap parse_san in Try/Except
Catch chess.InvalidMoveError, chess.IllegalMoveError, and chess.AmbiguousMoveError separately so your program can report exactly why a move failed instead of a generic error.
Push Only Validated Moves
Call board.push(move) only after a successful parse. Pushing an illegal move directly with from_uci skips validation and can corrupt your game state.
Report the Reason to the User
Map each exception type to a readable message: "Not a real move," "That move is illegal here," or "Ambiguous — specify which piece." Clear feedback prevents repeated bad input.
Test Edge Cases
Verify castling through check, en passant timing, and promotion notation like e8=Q. These are the positions where illegal-move bugs most often appear.
Never call board.push() with a move built from raw UCI strings without first checking move in board.legal_moves. Unlike parse_san(), UCI-based move construction performs zero rule validation.
Rule-Breaking Moves in Illegal Chess
While python-chess exists to reject illegal moves, Illegal Chess on Roblox exists to celebrate them. The game keeps the familiar chess objective — capture the enemy king — but layers on rockets, teleportation, freezing powers, and explosions that no rulebook would ever allow. If you are building tools, bots, or analysis projects around this game, the distinction matters.
Standard Chess
- Strict legality enforced
- Illegal SAN is rejected outright
- python-chess validation works perfectly
Illegal Chess
- Abilities override normal rules
- Special attacks bypass protected squares
- Board state can change mid-exchange
Hybrid Tools
- Use python-chess for baseline movement
- Extend with custom ability logic
- Flag ability-driven moves as sanctioned exceptions
| Situation | python-chess Result | Illegal Chess Equivalent |
|---|---|---|
| Moving a piece to an occupied friendly square | IllegalMoveError | Repositioning ability may allow it |
| Attacking a protected piece | Legal but unwise | Explosive abilities can trade through protection |
| Frozen piece attempts to move | No equivalent (piece simply has no moves) | Ability disables movement entirely |
| Two-step pawn without a two-step square | IllegalMoveError | Teleport effects mimic repositioning |
If you log Illegal Chess matches or build practice bots, record ability usage alongside standard moves. A plain SAN move list will not reproduce the actual game, because ability effects are not expressible in standard notation.
Debugging Checklist for SAN Validation Errors
SAN Validation Checklist:
- Confirm the SAN string has no stray spaces or hidden characters
- Check whether the move requires disambiguation (AmbiguousMoveError)
- Verify castling rights exist before parsing O-O or O-O-O
- Confirm en passant only on the immediately following move
- Validate the board state was not mutated before the failing parse
- Test promotion notation includes =Q or similar piece suffix
Print board.legal_moves in UCI form right before the failing call. Comparing the expected SAN against the true legal move list pinpoints the misunderstanding in seconds.
FAQ
Q: What is an illegal SAN move in python-chess?
It is a move string in Standard Algebraic Notation that is either syntactically invalid (raising InvalidMoveError) or describes a move that the rules do not permit from the current position (raising IllegalMoveError). Ambiguous notation for identical pieces raises AmbiguousMoveError.
Q: Does parse_san check legality automatically?
Yes. board.parse_san() validates both syntax and legality against the current position. If any check fails, it raises one of the three exceptions instead of returning a Move object, so always wrap the call in a try/except block.
Q: How does Illegal Chess the Roblox game relate to illegal moves?
Illegal Chess is a chaotic Roblox chess game where special abilities such as rockets, teleportation, and freezing deliberately break standard chess rules. Its gameplay is inspired by the same concept — moves no legitimate chess engine would accept — but it sanctions them as core mechanics rather than errors.
Q: Can I use python-chess to build an Illegal Chess helper tool?
Partially. python-chess handles baseline piece movement, board state, and standard notation, but ability effects like explosions and teleports are outside its scope. Extend it with custom logic that tracks ability usage separately from the SAN move list.