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.

DarkBASIC Discussion / I am making a chess game but I need help please

Author
Message
MASTER OF PUPPETS
20
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 4th Jan 2005 13:07
My chess game is 2d and you are looking at the board at a 90 degree angle straight down. What I was wondering is this...How could I program the limited movements of the pieces and how could I program the A.I.
Any help would be appreciated
Thank You!!!

metal is not music but a way of life...all hail to the reigning king METALLICA!!!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Jan 2005 16:22
I'd make a big list of every possible move for every piece, once you have your master list, you branch off and try to figure out which move has the best long term affect. By giving each piece on the board a score, then tallying the scores and comparing them between moves, you can find out what affect different moves have on the score. The idea is you give your king a really high score, then by going for the highest resulting move, it'll always try and get a checkmate.

I'd suggest giving each piece on your board a score first - you can work this out by plonking the piece alone in the middle of the board and counting how many moves it can make - this will tell you how powerful each piece is. Then tackling that list of possible moves will let you have a very basic game of chess quite quickly.

There is an old topic in the game design board, I've posted a lot more tips there if you fancy looking for it, I think it'll be on page 3 by now.


Van-B


It's c**p being the only coder in the village.
Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 4th Jan 2005 17:38 Edited at: 4th Jan 2005 18:46
Probably the easiest thing to is to write six functions. A function for each piece. Then send the function x,y coords and player 1,2 variable (black or white).

Another option is to use say data statements that hold the 8 directions a piece can move, weather the piece can bypass obstructing pieces (ie the knight), how limited the movement is for that piece, and if the piece is mutli-directional (ie. the pawn can't move backwards).

So, legal moves, starting and landing positions, pieces and the board. Chess is a pretty easy and good project to work on if you're a beginner.

Just don't forget about the most obscure move in chess that alot of games seem to leave out. Pawn en Passant.

This is a really good website for the rules of chess. http://www.conservativebookstore.com/chess/

Uh, I don't even wanna touch on the AI subject.

Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 4th Jan 2005 22:17 Edited at: 4th Jan 2005 22:19
Ya, I imagine that a chess AI would most likely be one of the hardest AI systems to make. However, you could try Van B's idea, which will give you a very basic AI system, but a person that is any good at chess will probably beat it like nothing. But, try it and see what happens because once you get a basic AI system working you can just keep improving it.

I made a small AI system for a tic tac toe game a while back. I wrote it like if the player goes in the middle and there is only one piece on the board then the AI would go in a certain spot. It ended up that the AI system was impossible to beat. This way would be quite impossible to make for a chess game because there's so many pieces and spots on the board, so if I were you I would go with Van B's idea.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Jan 2005 22:33
Yeah, to expand on that, you have to look at each possible move, and then work out the most likely opponent move, then with the new board layout you have to repeat the process until you know which core move will yield the best score. The last time I kept track of the board by storing each move in the same string of data - like maybe A2 gets moved to A3:

A2A3|

Then you would copy your buffer board and perform the move. From there you can work out the opponents likely move, and add that to the mix, say:

A2A3|B7B5

Then you keep doing that, bulding up your list and keeping track of each items score until you run out of AI brain, like if you want it easy, you might check 3 moves ahead, higher difficulties would require you to gather more data. The last time I did this I stored it all in a long string, which makes it easy to perform the moves because you just check the string a character at a time, and it's quick and simple to start a new move from an old one by using the same moves.

If you imagine your main data array is huge, any size really - because there could be thousands of moves, you have to keep track of each move in turn, and use board buffer arrays to move pieces and calculate score. For example you might have 2 boards, 1 for displaying, like the current board, and a calculator board, both are the same - but 1 should be treated as a buffer for the other one.

It's the managing of all this data that makes it difficult to program chess without some decent foreplanning - know how your data will be stored and accessed before you start coding or things can get very messy.


Van-B


It's c**p being the only coder in the village.
Nosnevel Xela
20
Years of Service
User Offline
Joined: 14th Dec 2004
Location: MA, USA
Posted: 5th Jan 2005 04:30
I hope you realize that if you can't figure out how to move the pieces, there is absolutely no way you're going to get chess AI. That's the kind of thing that MIT Geniuses work on.

Anyway, my suggestion is that you try to make 2 player chess first, where both players are humans sitting next to eachother at a computer. This eliminates AI completely. Once you've got that working, maybe then you can make it multiplayer, and then after that you can think about AI.
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 5th Jan 2005 04:36 Edited at: 5th Jan 2005 04:38
Ya, get a 2 player chess game working first, and then make a AI system, don't get yourself all mixed, just do one step at a time.
MASTER OF PUPPETS
20
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 6th Jan 2005 00:07
I dont know how I will make the AI but once I make the system for piece placement and movement I can imagine that it will become much easier. How would you make chess AI???

metal is not music but a way of life...all hail to the reigning king METALLICA!!!

Login to post a reply

Server time is: 2025-05-24 19:10:18
Your offset time is: 2025-05-24 19:10:18