Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
HowdyDewdy
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 6th Dec 2003 21:53
Anybody know how ot make a chess program.....w/ a GUI?

KAO
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 6th Dec 2003 23:40
Chess can be one of the most complex game too make. Mainlyh due to the A.I.

I am mischeivious
RoooooOoooooKoooooKoooooRoooooOoooooKoooooKooooo!
EricDB
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 7th Dec 2003 00:12 Edited at: 7th Dec 2003 00:15
Actually, a decent chess AI is not very complicated at all. I wrote one a few years ago that would not compare to any commercial program, but was able to consistently beat me.

Basically, it comes down to two aspects:
1) Evaluating a position (board and pieces) numerically
2) A recursive function to search a few moves ahead

I had a very simple method for evaluating a position. First I added up the point values of the pieces on each side. Then I counted how many pieces and empty spaces on the board were under attack from pieces on each side. Adding it up gave the numerical value for that position.

To choose a move, the program would take the current position, and make a list of all legal moves. Each move resulted in a new position, which was fed back into the same function recursively. Once a certain depth was reached, it stopped, and found the best position it had reached, then followed the tree back up to find out which move led to it, then made that move.

There are any number of clever optimizations that can be made, but I didn't. It still whooped the pants off of me though, running on a 33Mhz 486, without being any more complex than what I just described.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Dec 2003 14:22
Yeah, Chess AI isn't really a black art like a lot of people think, when it boils down to it, its basically simple maths that a kid could fathom out - you could actually play chess with yourself just by checking move scores.

The score of each piece can be found by sticking the piece in the middle of the board and counting how many spaces it can move to.

To calculate a board score, I'd have a buffer board and a set of functions to simply copy the real board over the buffer board, and calculate the buffer score for each player - just by adding the score of each piece to get a total. You'd copy the real board over the buffer board and perform each move, each time you could flag the spaces which could be attacked by your opponent, then adjust the score for the pieces under threat, I reckon subtracting the piece value once is enough - that's why you flag the threatened space, so each piece is only affected once - you don't want it going daft when a piece is under attack from 2 or more sides.
Really, once you have possible moves, and board scores working - the AI is really just data organising, checking lots of board layouts, and keeping track of the best scoring move - the trickiest part is the data organising.

I suggest storing each move by the XY location to destination location, like 12:32 would move the leftmost white pawn forward 2 space, xy:XY sorta thing where XY is the destination, and xy is the start. If you use this sort of data storage you should find adding moves a bit easier because it's a string, you simply join your moves together. Doing it this way means you could perform each move in turn to get the end score - making move analysis a bit easier for you, just make your functions super efficient.

For a UI, you only really need a check on the screen location of the piece, just have a little bounding box at it's base that selects the piece when clicked on. I expect chess programs to let me click on the square - obviously in DBPro you could probably use PICK SCREEN and all that gubbins that I don't understand yet.


Van-B


I laugh in the face of fate!
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 8th Dec 2003 15:28
check my site for a free chess game. There's enough there to get you started. I did not do AI though.

internet gaming group
HowdyDewdy
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Dec 2003 05:16
Whats a way to code that? Im notlooking for a straightforward "heres the code" kinda thing, just maybe some commands that would help, and somethign to follow

KAO
thedubdude
21
Years of Service
User Offline
Joined: 24th May 2003
Location: San Jose, Ca.
Posted: 12th Dec 2003 21:19
I am presently programming a chess spin off and might be able to help you. It has not been an easy project,though I'm really enjoying it. So far I've implimented all the basic functoinality including:

1. AlphaBeta search algorithm for searching the game tree.
2. MakeNextMove function
3. Generate Move function
4. Undo Move function
5. Evaluate Board function
6. Means to define the moves for each piece
7. Means to determine legal board moves
8. Many other support functions

I have no idea if my implimentation is the most efficient means to achieve the above functionality, but I'm willing to help you with what I know.

You can email me directly at: thedubdude@sbcglobal.net
HowdyDewdy
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 13th Dec 2003 23:27
thanks It is taking a while to type the possible moves the player can move

KAO

Login to post a reply

Server time is: 2024-09-21 11:43:46
Your offset time is: 2024-09-21 11:43:46