"independant thinking machine"

Hey,

Anybody here who has any experience in creating a chess engine? I've built one (the basic: valid move, move piece, isCheck, ...), but now I'd like it to be a machine people can play against.

I've got methods to get every possible move from each piece on the board, but how to make a method comparing them and thus "think"?

How should I start with that? Any comment, help, tips, ... are welcome

Smetje

[439 byte] By [smetjea] at [2007-11-27 8:32:53]
# 1

OK, so this is WAY out of my league here, but I thought I may be able to add a little something.

I can only imagine how many possible moves there are, but it would seem to me you need an algorithm which checks all the possible moves against each other to see which one is better. Now, there is probably someone amongst us that has done this before, so of course I could be way off. But how about implementing the comparable interface and comparing each move to the available moves?

For example, loop through all the available moves recursively comparing them against each other using compareTo() until you find the one move which is "better" than the rest.

Now there are several issues with this approach:

1) I have never done this and am LIKELY to be way off.

2) How would you define "better" moves?

Hope this gives you some ideas, but please post your solution as I (and probably others) am interested in this....

Kevin_Cloutiera at 2007-7-12 20:28:50 > top of Java-index,Java Essentials,New To Java...
# 2

They estimate that for a chess game with 40 turns there are 1.5*10^128 different possibilities - much more than there are atoms in the universe!

So you cannot "simply" compare all possible moves!

One algorithm is called "minmax":

http://en.wikipedia.org/wiki/Minmax

You would have to a restrict the search depth.

To improve you can feet your programm with well-known good/ bad moves.

Good luck! :-)

-Puce

Pucea at 2007-7-12 20:28:50 > top of Java-index,Java Essentials,New To Java...
# 3

i have some experience in this area:

ive built a checker AI uses the alpha-beta algorithm to decide on moves, and one which uses a neural network.

its easier to use alpha-beta, which is faster and smarter 90% of the time anyway.

since you say you have the method to get all moves on a board, all you need to do is pick one of those, this is usually done by evaluating the board.

google alpha-beta with pruning, board evaluation algorithms

also, for your refernce here are some links to my "game theory" projects:

checker ai based on a neural network:

http://doesthatevencompile.com/past-projects/2006/checker-neural-network-ai.htm

checker ai framework - allows you to implement an interface to make AIs:

http://doesthatevencompile.com/past-projects/2004/checkers-framework.htm

reversi applet which uses a alpha-beta pruning AI:

http://doesthatevencompile.com/past-projects/2004/reversi-applet/

mkoryaka at 2007-7-12 20:28:50 > top of Java-index,Java Essentials,New To Java...