
-----------------------------------
threatbinder
Thu Dec 10, 2009 9:51 pm

Coding Chess - Computer AI
-----------------------------------
Can anyone give me a basic idea on how to code the computer AI for a chess game? It doesn't have to be the actual code, but steps along the way for the game would be fantastic, thanks~

-----------------------------------
Tony
Thu Dec 10, 2009 10:02 pm

RE:Coding Chess - Computer AI
-----------------------------------
Similar to how you would play the game. You read the board, and pick one of all the possible valid moves to take.

I'm not sure what exactly you are asking here. The complexity depends on how "smart" you want the AI to be.

On the dumb scale, it could pick moves at random. That will work and it's easy to make.

On the other... well you need to be able to play the game yourself, and describe that process.

-----------------------------------
Insectoid
Thu Dec 10, 2009 10:26 pm

RE:Coding Chess - Computer AI
-----------------------------------
I suppose a min/max algorithm would be the way to do this. Chess AI is hugely complicated and probably not worth the effort without serious knowledge of the game and how it works.

-----------------------------------
threatbinder
Thu Dec 10, 2009 11:21 pm

Re: RE:Coding Chess - Computer AI
-----------------------------------
Similar to how you would play the game. You read the board, and pick one of all the possible valid moves to take.

I'm not sure what exactly you are asking here. The complexity depends on how "smart" you want the AI to be.

On the dumb scale, it could pick moves at random. That will work and it's easy to make.

On the other... well you need to be able to play the game yourself, and describe that process.

How exactly do you "read the board"? Do you measure where the x, y of a certain sprite is?

And you didn't really explain how the AI would be programmed.. as for the "easy mode", how would you go about doing the "random" moves? Do you make like 5 procedures for each and every single scenario that can occur in the game, and have it do a random one? (that was a complete guess / rhetorical question).

And for the expert AI, how would you program a smart version?

Please explain in more deph... ty.

-----------------------------------
A.J
Fri Dec 11, 2009 12:20 am

RE:Coding Chess - Computer AI
-----------------------------------
I present to you Wikipedia:
http://en.wikipedia.org/wiki/Minimax
http://en.wikipedia.org/wiki/Alpha-beta_pruning

Try implementing minimax for an easier game, like Tic-Tac-Toe (in which case it will be unbeatable). Then try tackling chess.

-----------------------------------
threatbinder
Fri Dec 11, 2009 1:09 am

Re: RE:Coding Chess - Computer AI
-----------------------------------
[quote="A.J @ Fri Dec 11, 2009 12:20 am"]I present to you Wikipedia:
http://en.wikipedia.org/wiki/Minimax
http://en.wikipedia.org/wiki/Alpha-beta_pruning

.. lol. I already started on my chess project, and please don't post wikipedia articles; don't you think I've already researched by now?

.. where did tic tac toe come from? Did I ask for a simpler project? I'm already half way through.

-----------------------------------
GalacticVenus
Fri Dec 11, 2009 7:27 am

RE:Coding Chess - Computer AI
-----------------------------------
Make it so that they move their queen onto their rook on turn one, then put you in Checkmate on turn two. :P

-----------------------------------
[Gandalf]
Fri Dec 11, 2009 1:11 pm

RE:Coding Chess - Computer AI
-----------------------------------
First thing is first; legal move generation and board representation (whether it be bitboards, an 8x8 array, an 0x88 array, etc.)

A great resource is:
http://chessprogramming.wikispaces.com/

-----------------------------------
Tony
Fri Dec 11, 2009 1:36 pm

Re: RE:Coding Chess - Computer AI
-----------------------------------
and please don't post wikipedia articles; don't you think I've already researched by now?
Hmm...
Can anyone give me a basic idea on how to code the computer AI for a chess game?
No. I don't think you have done adequate research. Otherwise you would have not only a basic idea, but some actual algorithms to reference (which is what A.J. is helping you here with).

-----------------------------------
threatbinder
Fri Dec 11, 2009 3:51 pm

Re: RE:Coding Chess - Computer AI
-----------------------------------
and please don't post wikipedia articles; don't you think I've already researched by now?
Hmm...
Can anyone give me a basic idea on how to code the computer AI for a chess game?
No. I don't think you have done adequate research. Otherwise you would have not only a basic idea, but some actual algorithms to reference (which is what A.J. is helping you here with).

I think I get the concept of a 2 player game now, so how would I go about programming the computer AI? I'll try researching more I guess for now.

-----------------------------------
threatbinder
Fri Dec 11, 2009 3:54 pm

Re: RE:Coding Chess - Computer AI
-----------------------------------
[quote="[Gandalf] @ Fri Dec 11, 2009 1:11 pm"]First thing is first; legal move generation and board representation (whether it be bitboards, an 8x8 array, an 0x88 array, etc.)

A great resource is:
http://chessprogramming.wikispaces.com/[/quote]

thanks for the article btw, i'll try reading some more. ^^

-----------------------------------
A.J
Fri Dec 11, 2009 6:08 pm

Re: Coding Chess - Computer AI
-----------------------------------

how would I go about programming the computer AI?

Well, that is what I am saying. Try looking-up the minimax algorithm, as it is very useful. I am sorry if my previous message seemed harsh to you, as I was only trying to help.

-----------------------------------
threatbinder
Fri Dec 11, 2009 8:11 pm

Re: Coding Chess - Computer AI
-----------------------------------

how would I go about programming the computer AI?

Well, that is what I am saying. Try looking-up the minimax algorithm, as it is very useful. I am sorry if my previous message seemed harsh to you, as I was only trying to help.

okay, thanks. I read your post the wrong way (thought you were trying to insult me with wikipedia articles... but then when you said go back to tic tac toe.. lol i must've misunderstood).

-----------------------------------
A.J
Fri Dec 11, 2009 11:08 pm

RE:Coding Chess - Computer AI
-----------------------------------
Its ok. Chess AI is pretty complicated, although it isn't impossible, merely time consuming.
