Here is my little project: A chess game for the Arduino Uno. It uses a graphics LCD as a user interface. Currently the DOGS102 shield and the DOGM128 shield are fully supported.
The chess game will be part of the next release of the dogm128 library. Meanwhile the source is available on request or at the project home page (browse source):
Including the graphics lib, the complete chess game requires about 12K flash ROM.
The pieces look a bit flimsy, but still very good for a board of 64x64 pixels.
If your graphical lib is integrated in those 12 KB of flash, how many bytes did you actually need for the Game ?
Personally I wouldn't know where to start programming and getting it under 16 KB seems a big achievement to me. I don't know whether I'll do something with it, but I'd very much like to have a look at the sketch used.
Most important question... How does it play ?
What response times do you get and is it able to offer you a worthy opponent ?
You will play against the ATMEGA. The 12K flash rom contains a full and working chess playing engine.
I will post some more details later.
Reaction is about 2 seconds or so, but I guess that the engine is quite weak (altough I never won against my engine... but this probably only means that I am a really bad player
olikraus:
You will play against the ATMEGA. The 12K flash rom contains a full and working chess playing engine.
I will post some more details later.
Reaction is about 2 seconds or so, but I guess that the engine is quite weak (altough I never won against my engine... but this probably only means that I am a really bad player
You designed a chess game engine? Bluddy brilliant!
I agree. I hadn't even considered someone would take on such a task. However if one thinks back
to the early apple II and Z-80 CP/M based computers, there were chess games being sold that worked.
The 328 and 1280 chips are certainly as powerful as those early processors. However with the small amount
of SRAM memory avalible it certainly must have been a challenge?
Here are some values on the program size
Graphics Lib and Font data: 6 KB
GUI, Bitmaps and Chess Engine: 5 KB
About the program development:
First I did research on existing chess engines. I found some very
small (regarding code size) engines, but they seem to be very cryptic and still use
a lot of ram. There is also one ATMEGA port of one engine, but I was not
able to understand how to control that engine.
The other issue has been the copyright. Many implementation did not fit to
the LGPL, which had been the intended license for the chess game.
And finally, I wanted a small implementation for the Uno. This requires
some tricks in C...
... so I started writing my own implementation. First step had been to implement
a "legal move finder". Once the program knows all legal moves for a color
and a given board setup, it is quite easy to setup a simple chess engine which
selects randomly a legal move.
I moved on and implemented a simple search algorithm for the best move.
The current algorithm is quite simple: negamax. Best move rating is mainly
based on the material. If you loose a rook, it is rated as a bad move.
Wow! I might win against a 32KB brain if I try my best. Never learned any techniques in chess. This is very cool! So what happened to the resistor in picture? Too large for back light so you put two parallel?
Oh, you noticed that little detail in the picture
I simply did some experiments with the backlight. The shield is ok, but its documentation according to some specific backlight colors is a little bit incomplete (http://schmelle2.de/wp/arduino/shields/dogm128-shield).
I also wonder it is deterministic; would two identical plays (from the player perspective) cause two equal outcomes?
Do you use well known openings? Or do you use the search from the get-go?
I've also written a simple chess engine as a part of my bachelor degree, the Alpha-beta pruning search is actually the source for my alias (also my initials A.B. aligns well).
Looks cool!
I'll have a look at the source one of these days
The evaluation function looks for the number of pieces and how are pieces placed on the board. So I would call this "board focused".
The engine does not use any random function. If you play the same moves, the engine will react always in the same way.
The engine does not have any opening database. So far I did not add anything which was not strictly required... to keep the program size as low as possible.
The Alpha-beta pruning search is the topmost item on my TODO list for the game engine.
However I did not fully understand that algorithm yet, so I am still afraid of its implementation.
This is very cool - definitely a contender for "top-10" Arduino GLCD games! I'm impressed that you coded your own engine (I tried such a thing once myself, a long time ago, and didn't get very far with it). I'm not surprised you were able to do it in the space (other than the RAM limitations); there used to be a 4K cartridge chess game for the TRS-80 Color Computer (though there wasn't as bad a RAM limit there, but it was pretty small).
I'm still waiting for someone to port Dungeons of Daggorath to an Arduino w/ a GLCD...