Ever wondered how the computer on LocalChess decides what to play? It isn't magic, and it isn't connected to a server — the whole opponent runs right in your browser. Here's a plain-English tour of how it works.
Step 1: Generate every legal move
Before the engine can choose a move, it needs to know its options. For the current position it generates all legal moves — every pawn push, knight hop, and castling option that the rules allow. This is the same rule logic that stops you from making an illegal move.
Step 2: Evaluate a position with a score
The engine needs a way to say "this position is good for me" or "this is bad." It does that with an evaluation function that produces a single number. The biggest ingredient is material:
Pawn = 1
Knight = 3
Bishop = 3
Rook = 5
Queen = 9
On top of raw material, the evaluation rewards good habits — pieces near the center, king safety, and active development. A positive score favors White; a negative score favors Black. That number is exactly what you see move in the evaluation bar on the left of the board.
Step 3: Search ahead with minimax
A single-move-deep evaluation is short-sighted — it might grab a pawn and walk into checkmate. So the engine looks ahead using an algorithm called minimax:
- Assume you will always play the move that's best for you.
- Assume your opponent will always reply with the move that's worst for you.
- Search several moves deep and pick the line that leads to the best guaranteed
outcome.
To keep this fast in a browser, the engine uses alpha-beta pruning — a classic trick that skips branches which can't possibly change the final decision. It lets the engine look deeper without checking every single position.
The deeper the search, the stronger — and slower — the engine plays. Balancing the two is the whole art of a browser chess bot.
What changes between Easy, Medium, and Hard?
The difficulty setting mostly controls how deep the engine searches and how much randomness it allows:
- Easy — shallow search and a dash of randomness, so it sometimes misses tactics
and gives beginners a fighting chance.
- Medium — a deeper, steadier search that punishes obvious blunders.
- Hard — the deepest search, playing the strongest move it can find in the time
available.
Try it yourself
Next time you play, open the Analyze game feature after a match. You'll see the same evaluation logic replay your game and point out where the balance shifted. Want to feel the difference? Play the same opening against Easy and then Hard and watch how much sharper the replies become.