chess on an arduino uno

Not sure about this being the right forum but....

Would there be any interest in a chess tournament for chess engines programed to run on a Uno (time frame is 18 to 24 months)

Chess is a larger project than most Arduino ones but not impossible, it has been done before on the ATMega88 (8k rom 1 k ram) and if you don't want to write your own, there are a few chess programs already in existence that can be ported and modified.

The idea is to introduce more complex programing to Arduino users and introduce actual hardware to chess engine programmers while staying within a low cost budget and well defined hardware - allowing anyone to compete on an equal footing and not giving the best chance to the biggest wallet.

Any thoughts?

Sounds very cool, I suppose the engine must have a Computer player (AI) right?

Would the Arduino be required to physically move the pieces around the board or just notify a human what move it wants to make?

How about having every piece move its self, i.e be a self contained micro + batteries + 2 motors + nrf24L01 to communicate as a team !

Sorry I have missed out some details.

For a tournament the uno just has receives and sends moves and some clock information via serial to either another arduino or a pc working as an adjudicator. It won't have to move or display anything as everything is going via serial port.

But...

to make the results more interesting and useful for hackers, modders and makers the intention is to add small limits on how many of the resources the chess engine can use for example it might be you have to leave 2k ROM free plus the unmodified Arduino boot-loader, 64 bytes of RAM and 64 bytes eeprom (enough to save a full game position and settings - but most engines wouldn't use eeprom at all).

After the tournament (or before if someone is really into it) these "unused" resources would allow the adding of simple displays, keypads, move take back, hints, etc to make it the project more interesting and enduring - but none of those things - although desirable - are needed for a chess engine to play another chess engine. I expect the best engines would be hacked into several different types of devices.

The chess engine is a type of AI - chess playing in software has been described as the "fruit fly" of AI. (the fruit fly is the simplest, genetic model of an organism, that is still useful in biology.

The full specs will be out soon if there is enough interest. That will have the notation and format the uno will use to communicate and details on what data will be provided. For example a clock giving the time remaining for both players, but if your opponent runs out of time and you don't claim a win, he can still play on until you do or he loses. As much as possible like human chess.

A useful if oldish book is "How computers play chess" by Levey and Newborn, although a bit more than half is taken up with background history and so forth. There is also a lot of information on the web, not all of it well written.

I find this a very interesting matter, but sadly one must have advanced knowledge on chess (don't you?) which I lack :sweat_smile:

This doesn't really sound like a competition that plays to the strengths of the Arduino ie interfacing to the outside world.

You are just using the constraints of the ATMega328 and the Arduino bootloader so that programmers are definitely constrained to a certain amount of ram and program space.

But if you then need to impose extra limits on the use of RAM and EPROM, you are somehow going to need to run metrics on the program as it runs, which is hard to do with custom hardware.

It would just be easier to run the program on the PC in some sort of sandbox that limits what it can do.
Or you'd be better off allowing people to do whatever they liked as long as they don't modify the hardware on the Uno, i.e in which case I suspect you'd see people doing clever things like removing the bootloader and also making use of the USB co-processor (ATMega8U2)

And chess on the AVR has been done before see https://chessprogramming.wikispaces.com/Micro-Max

Anyway, good luck with your project, but its not one for me.

mart256:
I find this a very interesting matter, but sadly one must have advanced knowledge on chess (don't you?) which I lack :sweat_smile:

If you can master the Uno you can master the rules of chess. Many good chess engines were written by people who know the rules of chess but play the the game poorly. (it is a myth that you can't write a program you can't beat)

I still don't see the point of writing the code to run on an Arduino and not even being able to use all its resources.

If you are going to set a challenge to get the best chess program on a Uno, allow people to use the whole Uno; rather than starting to add additional limitations

If you really want additional limitations, get them to write it on a ATMega168 based Duemilanove etc or a tiny45 or something.

Just connecting 2 Arduino's via serial, and getting them to play against each other is going to be like watching paint dry.

What are you going to do, get the winner to flash its LED on pin 13.

This sounds like an exercise in sucking the life out of something that could be interesting.
Allow people to overclock them at 100mhz and run them in liquid nitrogen etc.
Make it fun.

Play to the strengths of the Arduino not its limitations.

rogerClark:
This doesn’t really sound like a competition that plays to the strengths of the Arduino ie interfacing to the outside world.

You are just using the constraints of the ATMega328 and the Arduino bootloader so that programmers are definitely constrained to a certain amount of ram and program space.

But if you then need to impose extra limits on the use of RAM and EPROM, you are somehow going to need to run metrics on the program as it runs, which is hard to do with custom hardware.

**** Probably not. To make a competition open to people in any country it has to be a software competition or else you have to have people posting hardware all around the world - that is not going to work. With software it can be emailed or downloaded from the web, you can collaborate with someone half a world away and it costs nothing to send entries in

It would just be easier to run the program on the PC in some sort of sandbox that limits what it can do.

**** depending on time/development effort that might be exactly what happens. If you are writing your own engine and fine tunning the evaluation function that is exactly what you would want to do - for those who have trouble with that 2 uno’s connected to play against each other would work too, albeit slower.

Or you’d be better off allowing people to do whatever they liked as long as they don’t modify the hardware on the Uno, i.e in which case I suspect you’d see people doing clever things like removing the bootloader and also making use of the USB co-processor (ATMega8U2).

**** the bootloader has to stay just for easy loading of competitors in the tournament.

And chess on the AVR has been done before see https://chessprogramming.wikispaces.com/Micro-Max

**** Yes, I mentioned it had been done before. I suspect some people will download an engine (there are several which will easily fit) and add and modify the program to get best performance - or write your own from scratch. Both approaches are worthwhile exercises I think.

Anyway, good luck with your project, but its not one for me.

***** thanks

Were you intending to write something after quoting what I said ?

rogerClark:
I still don't see the point of writing the code to run on an Arduino and not even being able to use all its resources.

If you are going to set a challenge to get the best chess program on a Uno, allow people to use the whole Uno; rather than starting to add additional limitations

**** the limitation are at this point just an idea to keep the engines useful after the competition is over - then anyone can hack it and add whatever they want. If the programs already uses everything then that might not be possible. But I am listening, dropping the rom limitations is easily do-able - most wouldn't use it all and those that do will almost certainly use a fair chunk for an opening book. RAM might be more of a problem since it is so scarce everyone will try to use it all and that will reduce hackerbility later. Still kicking it around..

If you really want additional limitations, get them to write it on a ATMega168 based Duemilanove etc or a tiny45 or something.
I wanted some difficulty in the project ... not some cruelty...

Just connecting 2 Arduino's via serial, and getting them to play against each other is going to be like watching paint dry.

.... You have played chess then. It's not an action sport - I grant that (unless as you said, you motorize the pieces). Unfortunately chess is a mind game and shifting it to a computer won't change that. The idea is a web site keeping track of entries and the tournament itself. The chess engines are sent in to the tournament organizers and they run the programs on their hardware and hence take care of running the actual tournament and ensuring compliance and eliminate most forms of cheating (I can't think of any) - results and games then posted on the web site, hopefully almost real time (and maybe only some games). The only thing that gets difficult is if there are more entries than the supporting hardware can accommodate - which is why the bootloader has to stay intact.

I haven't been able to think of another way to do it. If people produce their own hardware to run the actual tournament on then they have to meet somewhere - which limits who can compete to a geographical region. If people are running the tournament on their own machines at home or connected via Internet then there will be all kinds of accusations of cheating. Some will be valid and some not, but sorting it out will be impossible and then how do you deal with an Internet drop out?

Last, the number of games needed to reach a result with the best engine on top is enough so such a tournament can't really be a one day affair. You need at least 2 x log2 (N entries) and that number assumes their are no mistakes due to bad opening books or any glitches in the running Uno's.

What are you going to do, get the winner to flash its LED on pin 13.

**** A pc will oversea see the results and act as adjudicator

This sounds like an exercise in sucking the life out of something that could be interesting.
Allow people to overclock them at 100mhz and run them in liquid nitrogen etc.
Make it fun.

****The idea is to make a level playing field. If you're a kid with $10 then as much as possible they will have the same chance as a 40 year old retired millionaire.

Play to the strengths of the Arduino not its limitations.

**** The strength of the Arduino is the community, the forums and resources. If I just need to flash lights I can use any old processor (but I do like the Arduinos).

rogerClark:
Were you intending to write something after quoting what I said ?

I'm used to Usenet. My stuff is intermixed with your post, look for the *********

I’m used to Usenet. My stuff is intermixed with your post, look for the *********

No worries. My bad…

****The idea is to make a level playing field. If you’re a kid with $10 then as much as possible they will have the same chance as a 40 year old retired millionaire.

Fair point.

Just make the requirement an unmodified Uno.

**** A pc will oversea see the results and act as adjudicator

Personally, I’d still not find it that interesting. But I guess you’re not appealing to everyone. You are just appealing to people who are interested in programing and in chess