Chess Mate

AVR based chess computer

Similar projects worth following
Chess Mate is an 80's style chess computer based on an ATMEGA328 slightly overclocked to 25MHz .

The ChessMate is an AVR ATmega328P running at 25 MHz with chess Engine based on recursive negamax search micro-Max 4.8 by H.G. Muller [1] (hash table removed by Andre Adrian).

Our contribution are the following features:
- Included Threefold repetition rule using Compact Chess Representation of history boards (C.C.R.) [2], we made it valid for the last 15 boards with 32 bytes per board; so the history boards occupies 480 bytes of RAM.
- Included the Fifty-move rule check (from fairy-Max [3]).

Processing Speed:
- For instance, the 32-bit test version of Rybka on AMD 64-bit CPU running on 2.4Ghz achieves 104 Knps (thousands of nodes per second) [2].

- The ATmega328P ChessMate at 25 MHz approach, can reach ~ 1.3 Knps (1298.1 nodes/s).

A node refers to a branch of play the computer investigated.

The following figure shows the nodes investigated versus move number (the engine was playing against itself):

FIGURE A1 - Nodes versus Move number (Chess engine playing against itself)

This table refers to the FIGURE A1 at Level 6 (Recursion Limit =1000)

MoveThinking time (ms)Nodes (depth)
43677.23 4859

[1] - Micro-Max, a 133-line Chess Source
[3] - Fairy-Max: an AI for playing user-defined Chess variants

  • 1 × ATMega328p Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × 78L05 Power Management ICs / Linear Voltage Regulators and LDOs
  • 4 × BC338 Discrete Semiconductors / Transistors, MOSFETs, FETs, IGBTs
  • 10 × 1N4148 Discrete Semiconductors / Diodes and Rectifiers
  • 1 × 1N4007 Discrete Semiconductors / Diodes and Rectifiers

View all 15 components

  • How to play

    Reinaldo de Sales Flamino02/16/2016 at 17:29 0 comments

    Initially, it should appear "PLAY" at the display

    • Press and hold "NEW" + the number of level
    • Enter your 4 digit move then press "ENTER"
    • Wait for lily thinking (it will be displayed blinking dots)
    • The lily move will be displayed just after the thinking
    • If you entered an erroneous digit; press "CLR", short press, to delete one digit
    • If you want to delete all digits entered, press and hold "CLR"

  • Video Demonstration

    Reinaldo de Sales Flamino02/16/2016 at 02:14 0 comments

    Here follows a demonstration of Lily chessmate playing against a mobile phone:

    Lily won when we were not recording... :~(

  • First working firmware release!

    Reinaldo de Sales Flamino02/15/2016 at 15:18 0 comments

    After many hours of testing and debugging ...

    First Release!

    Try yourself to beat Lily.

    Code available at github:


  • First game of Lily

    Reinaldo de Sales Flamino12/23/2015 at 13:54 0 comments

    Here follows the first game of Lily ChessMate against an Online Chess computer:

    [Event "First game of Lily"]
    [Date ""]
    [Round "-"]
    [White "Online Chess Computer at 3s per move"]
    [Black "Lily - ChessMate at Level 6/8"]

    [Result "1-0"]

    1. e4 Nc6 2. d4 d5 3. e5 Bf5 4. g4 Be4 5. f3 Bg6 6. h4 e6 7. h5 Bb4+ 8. c3 Bxb1 9. cxb4 Bxa2 10. Rxa2 Nxb4 11. Ra4 a5 12. Bd2 Nc6 13. Qb3 Ra7 14. Bb5 Qa8 15. Qa3 b6 16. Ne2 f5 17. gxf5 exf5 18. e6 Ne7 19. Bg5 Ng8 20. Qc3 Ne7 21. Bxe7 Kxe7 22. Bxc6 Qd8 23. Nf4 Qd6 24. Qc1 b5 25. Bxb5 Rb8 26. Bc6 g5 27. hxg6 hxg6 28. Rh7+ Kf6 29. Nh5+ gxh5 30. Qh6# *

    Online Chess Computer (WHITE) X Lily level 6 (BLACK)

  • Added debounce for ENTER and keys 1-8

    danjovic12/15/2015 at 01:45 0 comments

    After struggling with a pair of bugs that were caused by the remains of debugging instructions I've managed to put the debouncing/detecting routines to work.

    Now I have a global that stores the events related to the keys CLR, ENTER and Kyes 1-8.

    // return value in key status: bit  7 6 5 4 3 2 1 0
    //                                    | | | | \   /
    // CLR long=1/short=0 ----------------+ | | |  \ /
    // CLR event----------------------------+ | |   V
    // ENTER event----------------------------+ |   |
    // Key[1-8] event---------------------------+   |
    // Key Pressed (1..8)---------------------------+

    And here is a video of the detection working:

  • Debouncing/display routines

    danjovic12/11/2015 at 03:15 0 comments

    Testing the display refresh and debounce routine. So far only the CLR key is being tested whilst the display code is already fully implemented. Notice the fast presses at the final moments of the video. They do not change the display because the short press/noise treshold is 100ms (whilst the long press treshold is 600ms).

  • Lily is alive!

    danjovic12/07/2015 at 23:34 0 comments

    Despite the board being designed originally for common cathode displays, after assembly I have found that I made a mistake about the polarity of the LED display @Reinaldo provided. On the lack of another common anode display I have modified the board by using PNP transistors instead of NPN and feeding the emitters with VCC (instead of GND). That was fed back to the design and now the board has a solder jump to allow using either common anode or common cathode displays.

    The official name for the project is Chess Mate but it already have a codename: Lily

View all 7 project logs

Enjoy this project?



A.Armstrong wrote 03/22/2023 at 14:42 point

Can you please provide me the hex file? I am new to AVR compilers. If the hex file will work in Arduino Uno? Thanks in advance!

  Are you sure? yes | no

Andriy Makukha wrote 08/23/2018 at 04:01 point

It is worth mentioning that this project is very similar to the SHAH computer by Andre Adrian. He not only ported the micro-Max 4.8 chess engine to AVR back in 2008, but also built the chess computer on ATmega88 and ATmega644 chips in 2009: http/

His AVR Max chess engine can also run on Linux and Windows.

  Are you sure? yes | no

Andriy Makukha wrote 08/21/2018 at 10:15 point

Thrilling project! Is there a way to assess ELO rating of this device?

  Are you sure? yes | no

danjovic wrote 08/23/2018 at 00:57 point

Thanks! I can't tell you if there is a way to perform such calculation automatically, if this is what you meant to ask. In fact I am a lousy chess player, then the machine beats me absolutely. Please contact @Reinaldo de Sales Flamino , my partner on the project. He have implemented the chess part of the code.

  Are you sure? yes | no

Jrwn wrote 05/27/2016 at 07:50 point

Can i have the background study of it? Just for my thesis :) thanks in advance!

  Are you sure? yes | no

Brian wrote 12/10/2015 at 00:47 point

I really like the push-buttons you used. Where did you find them? Is it a clear cap that you can put your own label under? 

  Are you sure? yes | no

danjovic wrote 12/10/2015 at 01:19 point

Thanks, Brian. I got those from Ali Express ($15,00 for a lot of 100 switches). As you realized the caps are clear and I have custom labels beneath them. The switches are cheap and look great but the switch 'neck' can twist some degrees causing the misalignment that can be seen on the photo. 

  Are you sure? yes | no

Brian wrote 12/10/2015 at 01:36 point

Awesome. I will look for them. Can you give me a link? I want to make sure I get the same kind.

  Are you sure? yes | no

PointyOintment wrote 02/29/2016 at 02:10 point

"relegendable keys" is what you want to search for.

  Are you sure? yes | no

Oscarv wrote 12/09/2015 at 23:36 point

Ah, I see - Are you planning to publish the source code for the chess engine? Or are you using an existing one?

  Are you sure? yes | no

danjovic wrote 12/09/2015 at 23:57 point

The engine code is based on an existing chess algorithm ported to AVR by my friend @Reinaldo that is co-author of this project. It will be available as well in the github repository for the project.

  Are you sure? yes | no

danjovic wrote 12/09/2015 at 23:25 point

Thanks  @Oscarv ! And thanks also for the tips! I've followed a conservative design for driving the displays mostly because I've noticed some issues on brightness on the LED display from #Key Pass but I will strongly consider to eliminate them. The diodes could also be removed, as far as the only keys that are expected to be pressed together are CLR/NEW and one of the numbers (for starting a new game with the desired difficulty level), but they gave a retro look to the board as well as they helped me to route the board without jumpers (well there is one jumper but it is there intentionally).
By the way, your #KIM Uno as well as you PDPis projects are real wonders!

  Are you sure? yes | no

Oscarv wrote 12/09/2015 at 19:21 point

AVR Chess - excellent! On the schematics, I think you can leave out the transistors and diodes to simplify the board. I made a PCB with the AVR328, driving a segment led display and switches last year and found that the AVR can power 7 led segments directly from its pins, bright enough with a 1K resistor. Also, as long as you do not plan to press multiple keys at the same time, the diodes can be left out. See my KIM Uno project on Hackaday for a board with very similar schematics (it happens to play chess as well, though likely no match for yours...)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates