Project 02 · Rust · In progress
mi8ess
mi → mik8 → hatesess → chessmik hates chess
A chess engine written in Rust.
Board representation and FEN parsing are in. Move generation comes next, then search. A project for learning Rust.
Source goes public with move generation.
Position
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
- To move
- black
- Search
- —
- Depth
- —
- Nodes
- —
Reads the board. Can’t move on it yet.
Roadmap
Eight stages, from board representation to a playable engine. Two are done; move generation is next.
- 01Board
- 02FEN
- 03Move gen
- 04Perft
- 05Search
- 06Eval
- 07UCI
- 08Play here
Next up · 03
Move generation
Pseudo-legal moves first: every move each piece could make if checks didn’t exist. Then throw out the ones that leave the king in check. Perft comes straight after, to prove the counts are right.
- Pawn pushes, captures, promotions
- Knight and king jumps
- Sliding pieces: bishop, rook, queen
- Castling and en passant
- Legality: does the king survive?
Planned work, not started
Internals
A FEN string is a whole chess position in one line. Six fields, split on spaces. from_fen reads them in order and refuses anything it doesn’t understand.
Anatomy of a FEN
1rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR2b3KQkq4e35061
- 1Placement8 ranks, top to bottom
- 2Side to movew or b
- 3Castlingwhich rooks can still castle
- 4En passanttarget square, or -
- 5Halfmoveclock for the 50-move rule
- 6Fullmovestarts at 1
Digits are runs of empty squares. Upper case is white, lower case is black.
// handle the castling rights
let castling = parts.next().ok_or("Missing castling info in FEN")?;
if castling != "-" {
for castling_char in castling.chars() {
match castling_char {
'K' => board.can_castle_king_white = true,
'k' => board.can_castle_king_black = true,
'Q' => board.can_castle_queen_white = true,
'q' => board.can_castle_queen_black = true,
_ => return Err("Invalid castling char in FEN".to_string()),
};
}
}src/board.rs · lines 153–166, indentation trimmed
10 of its 20 error messages
- Err "FEN is empty"
- Err "Not 8 ranks in FEN"
- Err "More than 8 files in FEN"
- Err "Incomplete rank in FEN"
- Err "Invalid notation used in FEN"
- Err "Invalid color to move in FEN"
- Err "Invalid castling char in FEN"
- Err "Invalid file in en_passant in FEN"
- Err "Invalid rank in en_passant in FEN"
- Err "Extra input found in en_passant in FEN"
The name
mimik8h·ate·sessch·ess
The name reads mi-eight-ess, short for “mik hates chess”.