AI Contest : Chess

How cool would it be if we built chess AI’s around a central chess framework (Board data, and such) and then had them compete? Yea, I know its like that movie “ComputerChess” but I still think it would be fun.

Chess is a great game and I think it would be a real challenge to build a good chess AI that could beat other chess AI’s.

This would be a contest because your AI would be competing with the other contestants AI’s. Yes I am suggesting a contest.

So… Why is this in the contest board? Are you suggesting a new contest for creating AI for chess?

I’ve got a Java chess app lying around with three AIs implemented - dumb, dumber and dumbest :slight_smile: The game was called Tiny Chess because it was meant to be tiny - maybe I will enter it in the 4K competition.

If I recall correctly I modeled the board and the rules, so that for any board position I could get all possible moves.

The AIs then simply rank the moves according to various systems.

DUMBEST simply picks a move at random - it is officially the worst chess player in the world. You can play worse deliberately of course.

DUMBER is actually quite clever and can beat me. It loops through all its possible moves and scores the board: you get points for every move available to your pieces in the new position, you lose points for every possible move your enemy has, you get points for every piece you defend and every enemy piece you threaten (and vice-versa for the enemy). Then DUMBER simply takes the highest scoring move.

DUMB is exactly the same but looks two moves ahead and tries to instead of picking the move based on highest scoring position, it plays the next enemy move and scores its own move by the enemy’s score - I don’t know if it was an improvement, it was just too slow.

Thats pretty cool. For the DUMB or DUMBER you should have it increase the score also if the move to be made is a center controlling move.

Opiop, I edited the post to make myself more clear, but the answer is yes I’m suggesting a contest.

I don’t have the time to make an AI myself (maybe tomorrow), but I can share what I think is the general idea.

  1. Opening moves. Obviously working out all the possible combinations of even the first 2 moves won’t do you any good, so have a strategy defined to use all the time (or pick randomly from multiple).

  2. General play. This is the main challenge. My idea here would be to take the value of each piece (1 = Pawn, 3 = Knight/Bishop, 5=Rook, 9=Queen, 1000=King), and then brute force all the possible (valid, but that should go without saying) outcomes for the next 2 moves. Add numbers for the value of each piece you take, and subtract for each piece you lose. Make sure to average the opponents moves so you end up with a result close to halfway between best and worse case scenarios. Also add/subtract points for putting/getting in check. Then take the best outcomes, and compare how many moves the opponent has. The less moves available to them, the better. Then you can pick randomly from the available options, and do the first move of that sequence.

  3. Finishing moves. When you have taken out most of the opponents pieces, the previous techniques won’t work. II’m not entirely sure how to do this part, but you can figure this out your own way.

The reason above for having the king at such a value is to sway the AI away from moves that have any chance whatsoever of leading to checkmate (unless of course there is also a chance of putting the other player in checkmate).

I think this system is a good place to start, but would need lots of tweaking to have a chance in a proper game.

I’d probably just write a rating algorithm for all possible moves. It would probably factor in things like what pieces you’re getting closer to, if its opening up “better” moves, if it captures a piece(should also take in what piece it captures), whether you can/will get taken afterwards, if it guards another piece etc.

would be cool if you guys also did some machine learning stuff :open_mouth:

you need to organize a team to write the base for the chess app tho, i would be interested in helping, i got a free 7th period at school :smiley:

The base chess app should be a server so you can link up a bot and a bot, a bot and a human, or a human and human depending on the client. It would also require minimal effort if we also programmed a basic client.

I’ve already started working on something, and might be able to get it running in the next few hours.

EDIT: Nope, not going to get it done today. Someone else should do it instead. I’m too lazy.

well, scratch networking for now. Just write a Chess game with an API that’ll let you make moves, analyze board etc. then make a plugin system that allows people to load AI, networking comes later.

There are already quite a few such AI plugin frameworks out there for chess. Perhaps not in java, but the interfaces don’t prevent java AFAIK. AI in chess is more or less a done deal with a min/max tree pruning being the way to do it.

I think it is perhaps less interesting that some other games like Go, or Stratego.

I have made a simple minimax depthsearch Chess AI a while ago.
It did not handle all rules yet (like Castling), but was in a playable state.
(the cutoff heuristic was simply the value of pieces on the board, like 100 for the queen and 10 for a pawn)

For a competition, you just need to define an interface to talk to
-reset board
-assigned color
-move from - move to
-special actions like turning pawn, checkmate etc.

then each ai gets a runcommand and the recent parameters.

could also define a maximum time allowed to process for each AI to keep it fair